Date: Wed, 18 Dec 2002 18:34:40 -0000 From: "Barry Byrne" <barry.byrne@wbtsystems.com> To: "Mxsmanic" <mxsmanic@hotmail.com>, "FreeBSD Questions" <freebsd-questions@FreeBSD.ORG> Subject: RE: Getting Perl scripts to work as mail filters Message-ID: <NCBBIAMNAKDKFJIIGNPKGEGOKHAA.barry.byrne@wbtsystems.com> In-Reply-To: <OE31qwso6EsEWo2q0LZ00004187@hotmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
> -----Original Message----- > From: owner-freebsd-questions@FreeBSD.ORG > [mailto:owner-freebsd-questions@FreeBSD.ORG]On Behalf Of Mxsmanic > *** Well it looks like your script is being run - what should your script > do? *** > Heck, it's so simple I can list it here: > #!/usr/bin/perl > > while ($inputline = <STDIN>) > { > $inputline =~ s/18 Dec 2002/29 Dec 2013/; > print STDOUT $inputline; > } > The s/// stuff is just to give me some proof that the script saw the > message. I'm not getting anything at all now, though. > I assumed that writing to STDOUT would somehow get the message delivered, > but maybe not. But if that's not the way to get it delivered, > what is? The How do you expect sendmail to know which user to deliver to? By altering the aliases file, you have said to sendmail: Don't deliver to localuser 'mymail', Instead deliver to the script 'perlfilter' If you don't need your script to modify the data that get's sent, then you could just add another recipient in the aliases file: mymail: "| perlfilter", myusername If you want to modify the message before sending it elsewhere, you could do something like: #!/usr/bin/perl $SENDMAIL="/usr/sbin/sendmail -bm"; $MYADDRESS="me\@mydomain.com"; open(SENDMAIL, "| $SENDMAIL $MYADDRESS") or die "Can't open $SENDMAIL"; while ($inputline = <STDIN>) { $inputline =~ s/18 Dec 2002/29 Dec 2013/; print SENDMAIL $inputline; } close(SENDMAIL); > sendmail manual is not at all clear on this. I looked in sendmail.cf for > the name of some program to which perhaps I should pipe STDOUT in the > aliases file, but couldn't find anything. When the aliases file does not > specify piping of messages to some special program, who normally delivers > them? > > *** sendmail doesn't do anything with the STDOUT from your script. I'm nut > sure what you mean by 'delivers whatever comes out' - where would > it deliver > it? *** > > To my mailbox. I want the script to see incoming messages just > before they > get deposited in my mailbox on the server. From what I can understand of > how this works, some program actually receives the messages from sendmail > (?) and deposits them in my /usr/home/$USER mailbox, which appears to be > just a simple text file (I can't find any reference giving the format of > that, either). > It's running as root on my system. I thought it _had_ to run as root (?); > doesn't it have to access mailboxes that have only 600 access or > something? Older versions ran as root - current recommended setup is not to run as root. But that's another issue. - Barry 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?NCBBIAMNAKDKFJIIGNPKGEGOKHAA.barry.byrne>