XF 1.4 Automated Bounce Email Handling

Most forums need to deal with members whose email address becomes invalid. Sometimes the user will go ahead and change it, but other times your forum will fire off emails to this now invalid address. When this happens, if you have a bounce email address setup in XenForo (and possibly with the -f option enabled in the mail configuration), you will receive an email telling you about the failure.

Email delivery failures can happen for a wide variety of reasons. If you continually send to an address that has been disabled, for example, this can count against your domain/IP's email reputation. A lower email reputation can lead to reduced email deliverability as your domain may appear to be a spammer.

Therefore, when you are notified that an email can't be delivered, you may want to prevent further emails from being sent to that user. XenForo 1.3 added a new user state that represents an invalid email, but you had to manually change users into this state. With a decent size forum, this could be tedious and time consuming at best and impossible to manage at worst.

To handle this, XenForo 1.4 implements an automated bounce email processing system. This is a fairly detailed and technical system, but it allows an important maintenance action to be automated.

Automated Bounce Parsing
ss-2014-07-11_17-27-16.webp

The core component of this system is a process that reads emails from a specific account and then parses those emails to determine if they are bounce messages.

As bounce notifications will be sent to the value you enter for the "Bounced Email Address", you would enter the POP3 or IMAP details for that account here. Once you do that, the system will automatically start checking this account for bounce messages. Note that the emails in this account will be removed after reading so this account needs to be dedicated to bounces from your forum only.

Every email that is read from this account will be analyzed to determine if it fits a known type and the appropriate action will be taken (changing the user state to indicate that the email is invalid, if appropriate). This is all displayed in the email bounce log in the control panel:

ss-2014-07-11_17-38-46.webp


The action taken will depend on the content of the email. The sections below discuss why an email could be untrusted and the distinction between soft and hard bounces.

Bounce email notification parsing is notoriously difficult due to a wide range of servers that don't actually give good bounce responses. We have covered a number of common cases but this will certainly need to be expanded over time, so if you use this feature, keep an eye on the bounce log and let us know if you see emails that aren't being handled correctly. The "view original" link will take you to a raw output of the original email (headers and all encoded data). This data can be used to help us determine any additional cases to handle.

Note that you may get non-bounce emails to this address, such as delay notifications, challenge verifications and auto-replies. These will be logged, but they don't represent any errors so no action will be taken.

Bounce email logs will be maintained for 30 days.

VERP and Validation
While you would think that a bounce notification would always tell you who the email was sent to, you'd be wrong. Sometimes, the notification will only show you the address of the final recipient, and maybe they forwarded their email to another address. In rare cases, it might not list any address.

A common way around this is with a technique called Variable Envelope Return Path (VERP). The concept behind VERP is to encode the recipient email into the Return-Path header (which is where the bounce notification is sent).

Another important component is validating that the original email was actually sent by your forum. Without this, someone could manually create a bounce notification, send it to your bounce address, and trigger the bounce behavior for any email. By adding a validation hash into the return path, we can simply ignore any email that doesn't validate. This is what the "untrusted" component is in the email bounce log screenshot.

Let's look at a quick VERP example:
  • Bounce handler address: bounce@yourdomain.com
  • Email recipient: user@example.com
The VERP may look like: bounce+1234abcd+user=example.com@yourdomain.com. The "1234abcd" part is the validation key that is generated using a secret key.

Keep in mind that the Return-Path is never shown to the end user (unless they look at the raw email contents). The Return-Path and the From/Sender values are always unrelated.

ss-2014-07-11_17-58-14.webp


We would recommend enabling VERP support if you enable the automated bounce handling option. However, it does require that your SMTP server ignores anything after the + sign. This is quite common these days; Gmail does it, for example.

If you don't (or can't) enable the VERP option, we will embed this data in the original email via another header. Some bounce notifications include the original message (or the headers from it) and we can parse this data out of that. However, it may not be as reliable as the VERP option.

Soft and Hard Bounces
Bounce notifications report a wide range of issues. Some of these are unlikely to ever be resolved and others may be temporary or specific to a single message. This is where a soft and hard bounce distinction becomes necessary.

When a hard bounce happens, action will be taken immediately (setting the user state to indicate that their email is invalid). These issues are unlikely to ever be resolved, except maybe through dumb luck. Most commonly, this will be an invalid mailbox (the part to the left of the @ in the address).

Soft bounces include:
  • The recipient's mailbox being full
  • DNS/connectivity issues
  • The message being too long (as other messages may go through)
Soft bounces don't trigger the user state change until multiple messages bounce. The exact behavior is defined by a set of criteria:
ss-2014-07-11_18-06-50.webp

The criteria is designed to give the recipient (or their server admin) a chance to resolve the issue. If the limit was based solely on the number of emails, a flurry of messages in a short time span could trigger the soft bounce threshold.

Using the values in the screenshot, the email would only be considered invalid if:
  • We received 3 or more bounce notifications
  • The bounce notifications happened on 3 or more distinct days
  • The amount of time between the first and last bounce is at least 5 days
These values can be tuned to fit your needs and how strict you want to be.




Phew, that was a long one. Let us know if you have any questions or thoughts and keep an eye out for more 1.4 features being revealed soon.

Just a reminder: Please do not post suggestions in this thread (even if you feel they are related). Use the dedicated suggestion forum so they can be tracked; suggestions made in this thread are unlikely to be implemented.
 
Can we still use services such as Mandrill with this addition?
This doesn't change the process of sending emails at all (except for the return path value if the option is enabled, which is minor and was already changeable within the control panel).
 
The requirements are really only being able to receive bounce messages (which means the -f parameter enabled and working or using an external SMTP server) and the ability to access an email account via POP3/IMAP. The bounce email address/account needs to be dedicated to handling bounces from your forum.
 
I hope I understand. Would it be possible to receive bounce emails with my email client (e.g. Outlook or MacOS Mail-app) and manually sort it out? We have a very small user base, so this would not be an issue.
 
If I understand what you're asking, you can already do that in the current version.

upload_2014-7-12_21-45-43.webp


Set the Bounced Email Address to your own, and you will be able to process them manually. You could either set the user state (which prevents them using the forum until the email is updated) or you could contact them privately to resolve.
 
If an account gets the state 'bounced' then does that also remove all email subscriptions?

I ask because many bounces are indirectly caused by the forum / forum member, and is not an email issue. For example:
If I subscribe to all forums here, then I will get a mass of email notifications. Quite a few email providers will handle this as a spam attack and start bouncing.
Now lets say my email is alfa1@emailservice.com and that bounces. Since nothing is really wrong with my account and I am actively using it, I would like most people, open up another account at the same provider: alfa2@emailprovider.com and reactivate my forum account.
But surprise surprise, that starts bouncing as well. So I keep changing my email addresses around ad infinitum while xenforo.com climbs the charts of email spammers.

To prevent this mayhem, its very useful to remove all email notifications once the bounce state is added.

Also: how are verification bounces handled? i.e. a new user registers, but before verification, the email bounces. The best solution seems to just delete the user account.

Third question: is the system immune to delayed bounce messages? Some email servers are really slow. Like google for example. It can resend bounce messages weeks after the fact. Does the xf system ignore such delayed messages? The only way to do so, seems to cross reference it with the users email address or to add an identifier which is referenced to the users email address.
 
Last edited:
This is a much desired feature! We use Amazon SES to take care of our email and found that most of the bounced emails are sent to my SPAM folder. Will the system be able to check the spam folder of my bounce mail catching account?
 
If an account gets the state 'bounced' then does that also remove all email subscriptions?
No. While I take the point you're making there, that would really be a horrible experience for the average case (as email notifications from watching content would be exactly what would likely cause the bounce trigger).

Also: how are verification bounces handled? i.e. a new user registers, but before verification, the email bounces. The best solution seems to just delete the user account.
They count, but the state is only applied to valid users. (These users will never receive unrequested emails anyway.)

Again, deleting the account would be a pretty harsh reaction for something that could be a typo.

That said, if you wanted to be more aggressive with what you did in this case of a bounce action, you could really do whatever you wanted to do fairly easily.

Third question: is the system immune to delayed bounce messages? Some email servers are really slow. Like google for example. It can resend bounce messages weeks after the fact. Does the xf system ignore such delayed messages? The only way to do so, seems to cross reference it with the users email address or to add an identifier which is referenced to the users email address.
Well, delayed delivery is something that is in the spec. The sender will automatically attempt to delivery the message with increasing delays until eventually giving up. Only the final failure counts (it's the only bounce, the others are delay notifications). This can be after a week of attempting.

So no, we don't ignore a bounce message based on date. If there's a delay in delivery of the bounce message to you, we do use the date from the actual bounce email itself for soft bounce logging.
 
This is a much desired feature! We use Amazon SES to take care of our email and found that most of the bounced emails are sent to my SPAM folder. Will the system be able to check the spam folder of my bounce mail catching account?
It checks the inbox only. You would likely want to disable the spam detection or setup rules to ensure that bounces end up in the inbox.
 
Well, delayed delivery is something that is in the spec. The sender will automatically attempt to delivery the message with increasing delays until eventually giving up. Only the final failure counts (it's the only bounce, the others are delay notifications). This can be after a week of attempting.

So no, we don't ignore a bounce message based on date. If there's a delay in delivery of the bounce message to you, we do use the date from the actual bounce email itself for soft bounce logging.
I mean something different. Lets say the system receives a bounce message that a user its email is doesnt exist. The system changes the members account state. And the member is forced to change his email address, which he does. So all seems resolved.
But then another bounce message comes in. The bounce message relates to an outdated situation and to the old email address of the member. gmail can keep sending outdated bounces for weeks.

How does the system handle this? Will it ignore this irrelevant bounce or will it erroneously put the member back into bounce state?
 
The bounce behavior is tied to email addresses, so if it can't find a user with that address, it will be ignored.

The bounce log lists the email address; if you hover over it, it will tell you the user it was attached to if it found one. Similarly, if it's detected as a bounce, it will display the status code that was detected (either from the delivery status notification or one we parsed). The status code is used to determine the reason for the bounce and thus the behavior to take.
 
Awesome!

In regards to xenforo boards getting blacklisted: if the system receives a notifications that the site is blacklisted by email providers X, Y Z, then it may be useful to notify the admin that the site is blacklisted.
This will allow the admin to take action and to request to be taken off the blacklist.
 
Very nice feature indeed :)

I hope I understand. Would it be possible to receive bounce emails with my email client (e.g. Outlook or MacOS Mail-app) and manually sort it out? We have a very small user base, so this would not be an issue.

Looking at what was posted in the first post yes, you will be able to enable / disable this feature as you like and can handle this as you would have with any previous version.
 
Top Bottom