[plug] Receiving emails to a script

Cameron Patrick cameron at patrick.wattle.id.au
Tue Apr 6 17:25:07 WST 2004


Craig Ringer wrote:

| The only time I've needed to do this, I used Perl to poll the IMAP
| server for new messages in a special mailbox

Eww!

| It worked well, and avoided any gross procmail/aliases/.forward
| hacks

Procmail hacks are fun, though :-) I've never really played around
with .forward files, but you could probably do what you want using
procmail.  In my sendmail experience (which is incredibly limited), if
you put

	    |/usr/bin/procmail

in your .forward, sendmail will hand messages over to procmail.  Then
in your .procmailrc something like:

LOGFILE=$HOME/procmail-log

:0c
saved-messages

:0
| /path/to/your/script.pl

That'll keep a copy of messages in a saved-messages folder so you can
see what messages are coming in (handy for debugging) and also log a
summary of the headers of each message and any errors from your script
in procmail-log.  Procmail can also do things like only passing
messages with special subject lines, addresses, or whatever to your
script, which may or may not be useful to you.

Cameron.




More information about the plug mailing list