Page 1 of 1

Getting subscribed user from SES bounce messages

PostPosted: 7:34pm, Tue 22 Apr, 2014
by lgaetz
I have been using phpList 3.x with Amazon SES for months with success. One of the annoyances with SES is that message headers are rewritten so that bounces don't come back with the header information intact, the bounce address is only hidden in the body of the message. When processing bounces, all of the bounces come up "Unidentifed" with the subscriber field empty.

I have made a minor modification to my my install that will pull the bounce address from the body of the email, and populate the subscriber field so that manual processing of bounces is easier. In the file /admin/bounce.php immediately after line 139 (ver 3.0.5/6):

Code: Select all
  // these lines exist
  $guessedemail = $emailreq[0];
  // these lines added pull subscriber email address from body of
  // message using regex
  if ($guessedemail == '') {
    $email_body = $bounce['data'];
    $regex = '~{"bounceSubType":.*?,"bounceType":.*?.*?"bouncedRecipients".*?"emailAddress":"(.+?)"~';
    if ($matches[1][0]) {
      $guessedemail = trim($matches[1]);

The above code runs only if the code preceding it is unable to determine the subscriber that caused the bounce (variable: $guessedemail). It will look in the email body (variable: $bounce['data']) for the regex defined (variable: $regex) and pull the portion of the regex identified between parentheses as the email address. It significantly speeds up my bounce processing. A similar search could be done one the message header by applying a regex to the variable $bounce['header'].

I think this could easily be added as a core feature, allow a user to specify a regex in Config/Settings as a fallback for situations where the email is not automatically pulled from the bounce header.

Thanks to the all who make this project a reality.

Re: Getting subscribed user from SES bounce messages

PostPosted: 1:38am, Thu 17 Jul, 2014
by PeV

could you please post the amazon ses related part of your config.php file?