[Gloucs] Amusing dangers of procmail

Paul Broadhead gloucs at mailman.lug.org.uk
Sat Sep 20 16:05:06 2003


Hi all, thought I'd share my procmail mess-up:

I have an email-to-text service setup; an email sent to a certain
address gets the subject sms texted to my phone.  Great fun for messing
with stuff.

I thought I setup and new email address that copies the email to a real
email address that I can read on my computer as normal and also to my
sms email address.  Enter procmail.

I use fetchmail and sendmail to read my ISP mail and deliver it to local
users.  Procmail can be used to filter a users incomming email before it
hits their inbox - client independant.  I already have a number of
promail filters set up so adding another should be a simple process.
Here's what I did...

Add the following lines to $HOME/.promailrc, replace <stuff> with proper
stuff.

:0
* ^X-Envelope-To: <sms copying email address>
! <local username for local copy> <my sms email address>

You may have already discovered my blunder....

The first line says use the entire email, the second search for a line
beginning X-Env.., the third, forward the email to the specified email
addresses.

Now even the non-procmail savy will have seen my blunder....

The incomming email matches the new filter.  One copy is sent to my
local email account, another to the sms email address.  To coin a
phrase, job done. I fired off a test email and my phone bleeped.  Then
it bleeped again,and again, and again....    Something was wrong so I
quickly removed the lines from .procmailrc and set about deleted all the
text messages my phone had received.  There were many!  Oops!

Eventually I realised my blunder.  The copy send to the sms email
address was fine.  However, the copy sent to the local address passed
back though procmail and, as it was the entire email, triggered the new
filter again.  It was only sendmail spotting the email loop after many
iterations that saved the day.

I've now done things differently.

Regards,
Paul