I send out a weekly newsletter to subscribers of my newsletter.

I send email from noreply@example.com because I don't want people to be able to flood my own email box with replies when they receive the newsletter.

My subscriber details are neatly packed into a database. I have been working on a script that logs into the pop server of noreply@example.com to see the mail that has bounced (return to sender) so that I can remove email addresses in my database that is not working anymore.

The email addresses in my database has grown to hundreds of thousands and sending needless newsletters to thousands of non-working email addresses is just a big waste of time, bandwidth and processing power.

Up until now the only way I could reliably determine if an email is a bounced email with my script was to check if there is X-Failed-Recipients: in the header and if the Return-path: value is blank. There must be a better way?

The script works well but is missing about 30% of other bounced emails that does not contain X-Failed-Recipients: and where the Return-path: value is sometimes not blank.

Is there more reliable ways to determine if the email received to noreply@example.com is a bounced email so that I can take steps to remove the non-working email from my subscriber database?

I cannot just remove all email addresses from my database when there is a return email to noreply@example.com because people reply to noreply@example.com in the mistaken belief that someone will read it.

  • 1
    You can reduce the amount of noise in the noreply mailbox by setting a different (non-existent) Reply-To address in the messages you send. That will generate error messages for people who hit reply (so they will know they should not have hit reply) and leave only bounces in the noreply mailbox. – HBruijn Jun 7 at 13:48
  • What are you using for email? (O365, Google Apps, Postfix, Sendmail, Exim, etc.) Also, are you using mailing list software or are you doing it all yourself? – omniomi Jun 7 at 13:57
  • Exim is being used. I have written a custom script in Perl. – gpwr Jun 7 at 14:15
  • Do you have access to sending smtp server log files? – AnFi Jun 8 at 6:01
  • 2
    It would be much easier to work with connection-stage rejections than all the different formats of bounce messages. – Esa Jokinen Jun 8 at 19:46

I have been able to determine the bounced status of a message with a Perl module called Mail::DeliveryStatus::BounceParser

This module looks at the connection-stage rejections (smtp reply codes) inside the bounced message. When the smtp reply code starts with 5 then it was a definite failure. The smtp codes are available here: https://www.greenend.org.uk/rjk/tech/smtpreplies.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.