Beefy Boxes and Bandwidth Generously Provided by pair Networks Cowboy Neal with Hat
Just another Perl shrine
 
PerlMonks  

Call Perl via email

by htmanning (Scribe)
on Aug 04, 2011 at 01:26 UTC ( #918413=perlquestion: print w/ replies, xml ) Need Help??
htmanning has asked for the wisdom of the Perl Monks concerning the following question:

Monks, A long time ago I had a procmail script that was able to receive an email, parse it, and call a perl script with variables. I'm searching like crazy and can't find a way to do this. Can someone point me in the right direction? I'd like to be able to send an email to a specific address, take the subject and body of the email, pass it to a perl script which will update a database and send out an email notification. Possible? Thanks.

Comment on Call Perl via email
Re: Call Perl via email
by davido (Archbishop) on Aug 04, 2011 at 04:36 UTC

    Do you still have access to procmail? What is your incoming mail handler? Or are you thinking of something that would sit between Outlook and some pop3 account?

    We would need to know where the hooks are before a solution can be suggested, and that will depend on what currently handles your incoming mail.


    Dave

      This would be on an apache server hosted at Pair Networks. I believe I could use Procmail, but I'm not tied to that.
Re: Call Perl via email
by thewebsi (Beadle) on Aug 04, 2011 at 05:33 UTC

    I wonder if this is more of a Procmail question than Perl... I do that through Postfix, in a file called /etc/postfix/master.cf. It automatically parses out any header fields I want, and passes it to any script. Procmail instructions are here.

Re: Call Perl via email
by gnosti (Pilgrim) on Aug 04, 2011 at 08:07 UTC
    Here is a way to do it without procmail using Email::Filter and a sendmail interface such as Email::Sender.

    In ~/.forward

    | filter_mail

    In ~/bin/filter_mail

    use Email::Filter; my $mail = Email::Filter->new(emergency => "~/emergency_mbox"); $mail->accept("$ENV{HOME}/Mail/new") unless $mail->subject =~ /magic_k +eyword/; # usually exit here send_mail(); sub send_mail { # see docs for Email::Sender }
Re: Call Perl via email
by JavaFan (Canon) on Aug 04, 2011 at 09:04 UTC
    That's not a Perl question, it's procmail question. The answer lies in the procmailrc manual page, section Recipe action line.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://918413]
Approved by muba
Front-paged by ww
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (12)
As of 2014-04-17 11:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (445 votes), past polls