Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

pager forwardinator

by vulcanrob (Initiate)
on Jul 05, 2005 at 00:39 UTC ( [id://472333]=sourcecode: print w/replies, xml ) Need Help??
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);

}

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: sourcecode [id://472333]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (7)
As of 2024-03-28 19:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found