[kwlug-disc] how to tell programmatically that mail was undeliverable?
Chris Irwin
chris at chrisirwin.ca
Wed Mar 31 11:03:43 EDT 2010
On Wed, Mar 31, 2010 at 09:30, Robert P. J. Day <rpjday at crashcourse.ca> wrote:
> however, given a properly-configured mail server at the other end,
> is there some RFC-approved notification that is *required* to be sent
> back so that i can verify the situation with as little muss and fuss
> as possible? thanks.
SMTP has specific codes, but that only covers the actual SMTP
communication channel. If you're parsing the failure *notices*, then
that is dependant on the implementation of the specific software
running the mail server. The notices are targeted at users, not
machines. I don't think there is a specific requirement for those
notices in terms of headers, mentioning codes, or even language.
Furthermore, you might not even get proper SMTP error codes in the
case of SMTP gateways (i.e. spam filters) which don't necessarily know
anything about users. Errors about full mailboxes may not occur until
after another SMTP hop in an organization. So even if you bypass your
relay and connect to their public MX directly, you're not necessarily
getting proper (or any) error codes. You'd also be bypassing any SPF
outbound mail rules you may have specified, thus making yourself look
like spam.
To top it off, I've seen some mail servers configured *not* to bounce
undeliverable notices. Logic being that there is so much undeliverable
mail to random addresses that it is not worthwhile in terms of
bandwidth to bounce undeliverable messages, which are most likely
spam. Plus forged envelope headers are so prevalent that some
businesses don't wish to send out failure notices to that unlucky
third party.
The route you are taking is probably the only way, building a filter
list of recognized notices. You could have your checker pass on
anything that passes through those filters for your observation (to
make a new rule). But will always have false negatives: Mail you think
got delivered that actually didn't.
Another option would be requesting Read Receipts. But support for
these depends on Mail reader and user preference (I never send them),
so your results will vary widely based on your target audience. It is
also a surefire way to annoy folks, since most capable MUAs prompt to
send read receipts.
The last option I can think of is embedded images. In the past an HTML
email would contain an image such as
"http://example.com/image.jpg?address@example.com". You would have to
customize the mail for each address, rather than using a big BCC. You
could then parse your web server's logs for addresses. However, I
think this is a dead art. AFAIK, Most mail clients, and all web-mail
clients filter out images from the web by default.
To sum up, technically SMTP itself has codes for this sort of thing,
but you are probably not going to get the proper codes back during
communication. You may or may not get unstandardized notices which
will differ based on mail software, localization, and sysadmin
preference. There are other methods to track delivery, but that they
are not guaranteed, and may give you less accurate results.
Sorry I couldn't be more help.
--
Chris Irwin
<chris at chrisirwin.ca>
More information about the kwlug-disc
mailing list