Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Dealing with returned mail

by weierophinney (Pilgrim)
on Jun 21, 2005 at 11:40 UTC ( [id://468636]=note: print w/replies, xml ) Need Help??


in reply to Dealing with returned mail

As somebody else mentioned, make sure that the SMTP envelope sender is the email address to which you want to receive bounces. Ideally, you want this to be a unique user, so that as you handle emails, you can be fairly certain they're bounces only. Most MTAs will respect that address as the originating address; you can't do much about the others.

Then, on the machine that hosts that email address, you need to put in a filter of some sort. Check to see if your server has procmail or maildrop installed. Then write a recipe for that address that processes incoming mail, searching for bounces, and searching in bounces for the original recipient -- this is where perl comes in, as you'll have your filter call a perl routine that will scan the incoming mail. The method for doing so will vary based on the MTA you use, but most have some easily identifiable block within bounced mail showing the original headers, and you can use a regex on those. Then update your database.

Always keep in mind that a message may bounce because (a) a user's account has temporarily exceeded quota, (b) a user's MTA is temporarily down (power failure, maintenance), (c) old DNS for a user's host is cached in the MTA, etc. It's best not to remove a user based on a single bounce. Where I work, we remove a user based on a formula involving consecutive bounces and frequency with which we mail the user. This means that when we update our DB, we're actually incrementing a 'bounced' count. A cronjob then goes through the list later and checks those with high bounce counts to determine if they should be removed.

Good luck!

Replies are listed 'Best First'.
Re^2: Dealing with returned mail
by cosmicperl (Chaplain) on Jun 24, 2005 at 00:17 UTC
    Thanks everyone. Just one question. How should I formation the prints to sendmail so that the SMTP envelope sender and bounce to addresses are configured correctly? At the moment I'm just using an open command following by some print statements for the TO: FROM:, etc.

    Also do you think I could use POP3 to check the bounce email address? That way the script could be contained and run on any hosting account? Or aren't the pop3 modules included in the core?

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (7)
As of 2024-04-18 09:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found