Written on 22 Dec 2018.
When you send out an auto-reply from an email system you want to take care to not send replies to automatically generated emails. At best, you will get a useless delivery failure. At words, you will get an infinite email loop and a world of chaos.
Turns out that reliably detecting automatically generated emails is not always easy. Here are my observations based on writing a detector for this and scanning about 100,000 emails with it (extensive personal archive and company archive).
Defined in RFC 3834.
This is the ‘official’ standard way to indicate your message is an auto-reply.
You should not send a reply if
Auto-Submitted is present and has a value
Defined by Microsoft
This header is used by Microsoft Exchange, Outlook, and perhaps some other
products. Many newsletters and such also set this. You should not send a
DR (“Suppress delivery
AutoReply (“Suppress auto-reply messages other than OOF
Defined in RFC 2919
You usually don’t want to send auto-replies to mailing lists or news letters. Pretty much all mail lists and most newsletters set at least one of these headers. You should not send a reply if either of these headers is present. The value is unimportant.
Defined by Google.
Gmail uses this header to identify mail newsletters, and uses it to generate statistics/reports for owners of those newsletters. You should not send a reply if this headers is present; the value is unimportant.
The above methods are well-defined and clear (even though some are non-standard). Unfortunately some email systems do not use any of them :-( Here are some additional measures.
Not really defined anywhere, mentioned in RFC 2076 where its use is discouraged (but this header is commonly encountered).
Note that checking for the existence of this field is not recommended, as some
normal and some other (obscure) values (this is not very common
My recommendation is to not send a reply if the value case-insensitively
A collection of other (somewhat obscure) headers I’ve encountered. I would recommend not sending an auto-reply if one of these is set. Most mails also set one of the above headers, but some don’t (but it’s not very common).
X-MSFBL; can’t really find a definition (Microsoft header?), but I only have
auto-generated mails with this header.
X-Loop; not really defined anywhere, and somewhat rare, but sometimes it’s
set. It’s most often set to the address that should not get emails, but
X-Loop: yes is also encountered.
X-Autoreply; fairly rare, and always seems to have a value of
Check if the
Reply-To headers contains
If an email only has a HTML part, but no text part it’s a good indication this is an auto-generated mail or newsletter. Pretty much all mail clients also set a text part.
Many delivery failure messages don’t really indicate that they’re failures. Some ways to check this:
Mail Delivery Subsystem
Many mail libraries leave some sort of footprint, and most regular mail clients override this with their own data. Checking for this seems to work fairly well.
X-Mailer: Microsoft CDO for Windows 2000 – Set by some MS software; I can
only find it on autogenerated mails. Yes, it’s still used in 2015.
Message-ID header contains
.JavaMail. – I’ve found a few (5 on 50k) regular
messages with this, but not many; the vast majority (thousends) of messages
are news-letters, order confirmations, etc.
^X-Mailer starts with
PHP. This should catch both
X-Mailer: PHPmailer blah blah. The same as
X-Library presence; only Indy
seems to set this.
X-Mailer starts with
wdcollect. Set by some Plesk mails.
X-Mailer starts with
Even when following all of the above advice, you may still encounter an email
program that will slip through. This can very dangerous, as email systems that
IF email THEN send_email have the potential to cause infinite email
For this reason, I recommend keeping track of which emails you’ve sent an autoreply to and rate limiting this to at most n emails in n minutes. This will break the back-and-forth chain.
We use one email per five minutes, but something less strict will probably also work well.
The specifics for this will vary depending on what sort of mails you’re sending. This is what we use for auto-reply mails:
Auto-Submitted: auto-replied X-Auto-Response-Suppress: All Precedence: auto_reply