Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 19 Dec 2002 01:40:15 +0100
From:      Mark <admin@asarian-host.net>
To:        "Mxsmanic" <mxsmanic@hotmail.com>, "Barry Byrne" <barry.byrne@wbtsystems.com>, "FreeBSD Questions" <freebsd-questions@freebsd.org>
Subject:   Re: Getting Perl scripts to work as mail filters
Message-ID:  <200212190040.GBJ0EIT60331@asarian-host.net>
References:  <OE51Z9rWjAKYVpMmOlb00005e1f@hotmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
----- Original Message -----
From: "Mxsmanic" <mxsmanic@hotmail.com>
To: "Mark" <admin@asarian-host.net>; "Barry Byrne"
<barry.byrne@wbtsystems.com>; "FreeBSD Questions"
<freebsd-questions@FreeBSD.ORG>
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 majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200212190040.GBJ0EIT60331>