Getting subscribed user from SES bounce messages

Version 3 Solutions you have discovered or come across should go here. Questions should go in the other three Version 3 forums, thank you.
Forum rules
Please do not ask questions here, this is for Version 3 Solutions you have discovered or come across.

Getting subscribed user from SES bounce messages

Postby lgaetz » 7:34pm, Tue 22 Apr, 2014

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.
Posts: 9
Joined: 1:51pm, Thu 22 Aug, 2013

Re: Getting subscribed user from SES bounce messages

Postby PeV » 1:38am, Thu 17 Jul, 2014


could you please post the amazon ses related part of your config.php file?
phpList newbie
Posts: 1
Joined: 1:35am, Thu 17 Jul, 2014

Return to Answers, HowTos, Tips and Tricks

Who is online

Users browsing this forum: No registered users and 1 guest