| Category: | E-Mail Programs |
| Author/Contact Info | vulcanrob, earth, unfashionable western spiral arm of the milky way galaxy |
| Description: | I used to have exim on my server and it did some fancy forwarding so copies of user@mydeparment.university.edu were forwaded to my pager. I switched to postfix (and love it), but postfix doesn't do fancy forward filtering, and who wants bloated procmail, so I made a little perl script that does the trick.
just put this in your .forward: \username, |/home/username/thisscript Postfix will pass the email to the script and away you go. This is the first in my continuing series of "poorly commented, slapped together scripts from rob" Next I want to see how to redirect any errors generated by this script. Right now they are emailed to the sender of the emailt hat triggered the script - not too helpful. live long and prosper |
do { $line = <STDIN> } until ($line =~ /^From:/i);
if ($line =~ /\@my\.university\.edu/i) {
##replace the email bit with whatever you want
open (MAIL, "|/usr/sbin/sendmail 3055551212\@mypager.net") ||
die "Can't open mail program:$!";
$line =~ /(\w+)(.)(.)\@bio/i;
print MAIL "From:$1\@$2\.$3\n";
$endhead = 1;
while ( $line = <STDIN> ){
if ($line !~ /\w/) {$endhead = 0};
# the above line looks for the blank line separating the body of
# the message from the headers, once it sees it, it starts sending
# the body in the email
print MAIL "$line" unless (($line =~/^>/) || ($endhead));
# the /^>/ looks for text quoted back to me and doesn't send that
# to the pager. I don't want to see the drivel I wrote again on
# my pager
}
close (MAIL);
}
|
|
|
|---|