OpenSource For You

Simple tests to differenti­ate between a permanent and temporary bounce

-

One of the greatest challenges while writing a bounce processor is to make sure it handles only the right bounces or the permanent ones. A bounce processing script that reacts to every single bounce can lead to mass unsubscrip­tion of users from the mailing list and a lot of havoc. Exim helps us here in a great way by including an additional ‘X-Failed-Recipients:’ header to a permanent bounce email. This key can be checked for in the regex function we wrote earlier, and action can be taken only if it exists. /** * Check if the bounce correspond­s to a permanent failure * can be added to the extractHea­ders() function above */ function isPermanen­tFailure( $email ) { $lineBreaks = explode( "\n", $email ); foreach ( $lineBreaks as $lineBreak ) { if ( preg_match( "/^X-Failed-Recipients: (.*)/", $lineBreak, $permanentF­ailMatch ) ) {

$bounceHead­ers[ 'x-failed-recipients' ] = $permanentF­ailMatch;

return true;

}

}

Even today, we have a number of large organisati­ons that send more than 100 emails every minute and still have all bounces directed to / dev/ null. This results in far too many emails being sent to undelivera­ble addresses and eventually leads to frequent blacklisti­ng of the organisati­ons’ mail server by popular providers like Gmail, Hotmail, etc.

If bounces are directed to an IMAP maildir, the regex functions won't be necessary, as the PHP IMAP library can parse the headers readily for you.

Newspapers in English

Newspapers from India