Welcome to WebmasterWorld Guest from

Forum Moderators: phranque

Message Too Old, No Replies

Using procmail, php and mysql to blacklist email

9:51 pm on Jan 19, 2010 (gmt 0)

Junior Member

10+ Year Member

joined:June 9, 2004
votes: 0

Hi guys,

I'm in the process of setting up a system where new email comes in, hits procmail, is sent to a .sh script, uses php to access mysql to identify if the sending IP is in my blacklist and delete it if it is.

I have my procmailrc using this recipe while I test things:

:0 Whic:test.lock
* ^To:.*testemail

:0 Wa

I am able to have my script identify if an email should be let through or deleted, but I am having problems sending that information back to procmail so it can delete the blacklisted emails.

If you happen to have gone through something similar, or have some suggestions, I would dearly love to hear them :)

The shell/php script takes the header of the email, identifies the originating IP address and checks the mysql database...everything tests well and I end up with 2 possible variables called $safe and $bad. I guess the question is, how do I (if it's possible) have the procmail delete the email if the originating IP ends up tagged to the $bad variable.

I looked around to see if I could find the best place to put this question, hopefully this was suitable :)

12:07 am on Jan 20, 2010 (gmt 0)

Senior Member from KZ 

WebmasterWorld Senior Member lammert is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Jan 10, 2005
votes: 35

procmail checks the contents of the email after processing. You could add an extra header line to the message, for example X-Real-Junk: Yes. The following procmail lines will send that message then to the write-only /dev/null mailbox.

* ^X-Real-Junk: Yes


Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members