----- Original Message ----- From: "Mxsmanic" <[EMAIL PROTECTED]> To: "Mark" <[EMAIL PROTECTED]>; "Barry Byrne" <[EMAIL PROTECTED]>; "FreeBSD Questions" <[EMAIL PROTECTED]> Sent: Thursday, December 19, 2002 1:13 AM Subject: Re: Getting Perl scripts to work as mail filters
> What about appending directly to the mailbox file under /var/mail/$USER > with the script? Possible, but not ideal. Be sure, in that case, you familiarize yourself with the assorted locking mechanism in question -- especially that of qpopper, for instance (if that is what you use to retrieve mail, of course), or mail may become lost. > It looks like the format of the file is very simple. Yes, standard mbox format. > Why wouldn't that work? It would, if done properly. :) > I don't know that calling sendmail again would be _that_ hard. Certainly possible (as has been suggested already, be careful you do not wind up in a loop, though). Like so, for instance: $mailprog = '/usr/sbin/sendmail'; open (MAIL, "| $mailprog -f$sender $recipient") || die $!; print MAIL "$header$body"; close (MAIL); The -f override is so the envelope sender will remain the original sender. Then you need to work a few things out with trusted users and all, to avoid "authwarnings" within the message. But a second invocation of sendmail from your Perl-script is sure possible. > After all, > I'm mostly just copying the input to the output. I guess all I'd have to > do would be to change the recipient address to avoid a loop (?). > Right? Can't I just leave all the headers intact otherwise? Headers are all part of the DATA stream, so they have no bearing on where sendmail delivers mail (unless you run sendmail with the -t option, which is generally ill-adviced anyway). The recipient given to sendmail as parameter (see above) is what will be used for delivery. No need to change the headers for that (as, like I said, they are part of the DATA stream). - Mark To Unsubscribe: send mail to [EMAIL PROTECTED] with "unsubscribe freebsd-questions" in the body of the message