Failed E-Mail templates

Greg K's picture

He has: 2,145 posts

Joined: Nov 2003

This idea came from another message in this area, that led me to an idea of a script, to handle mail that comes back from mail servers to let you know that e-mail your script sent out went to a bad address on their server.

(NOTE: This is not dealing with invalid formatted e-mail addresses, but ones failed for a nonexistant domain, or invalid mailboxes at valid domains).

So I created this thread to show samples of what failure messages look like, to help write a script to handle them.

When posting samples of actual responces you got, like the ones I'm posting below, please be sure to edit out domain names, replace them with [DOMAIN] and the mailbox with [USER] so it would be "[USER]@[DOMAIN]", However, please leave any original names from the mail server (but remove the derver domain name, ie. "postmaster@[DOMAIN]") Remember, on all these samples, the TO: field will most likely be the address you set your script to use as a FROM address, so I'm leaving those out of the samples.

Also, I think we only need to post enough info to get to the reason the mail was rejected, and the address you were trying to send it to.

Quote: From: System Administrator
Subject: Undeliverable: [SUBJECT]

Your message

To: [USER]@[DOMAIN]
Subject: [SUBJECT]
Sent: Tue, 30 Jan 2007 23:34:40 +0800

did not reach the following recipient(s):

[USER]@[DOMAIN] on Tue, 30 Jan 2007 23:25:57 +0800
The recipient name is not recognized

Quote: From: Mail Delivery Subsystem
Subject: Returned mail: see transcript for details

The original message was received at Tue, 30 Jan 2007 09:22:15 -0800
from [MY MAIL SERVER] (may be forged)

----- The following addresses had permanent fatal errors -----
<[USER]@[DOMAIN-2]>

----- Transcript of session follows -----
554 5.0.0 MX list for [DOMAIN-2]. points back to [DOMAIN-1]
554 5.3.5 Local configuration error

Quote: From: Mail Delivery Service [DOMAIN]>
Subject: [SUBJECT]

- These recipients of your message have been processed by the mail server:
[USER]@[DOMAIN]; Failed; 5.1.1 (bad destination mailbox address)

Quote: From: Mail Delivery System [DOMAIN]>
Subject: Mail delivery failed: returning message to sender

This message was created automatically by mail delivery software (Exim).

A message that you sent could not be delivered to one or more of its
recipients. This is a permanent error. The following address(es) failed:

[USER]@[DOMAIN]
unknown local-part "[USER]" in domain "[DOMAIN]"

Quote: From: MAILER-DAEMON@[DOMAIN-1]
Subject: failure notice

Hi. This is the qmail-send program at [DOMAIN-1].
I'm afraid I wasn't able to deliver your message to the following addresses.
This is a permanent error; I've given up. Sorry it didn't work out.

<[USER]@[DOMAIN-2]>:
Blocked SA=15!
Spam blocked.

Quote: From: postmaster@[DOMAIN]
Subject: failure notice

Hi. This is the qmail-send program at [DOMAIN].
I'm afraid I wasn't able to deliver your message to the following addresses.
This is a permanent error; I've given up. Sorry it didn't work out.

<[USER]@[DOMAIN]>:
Sorry, no mailbox here by that name. (#5.1.1)

Quote: From: MAILER-DAEMON@[DOMAIN]
Subject: failure notice

Hi. This is the qmail-send program at [DOMAIN].
I'm afraid I wasn't able to deliver your message to the following addresses.
This is a permanent error; I've given up. Sorry it didn't work out.

<[USER]@[DOMAIN]>:
This address no longer accepts mail.

Quote: From: postmaster@[DOMAIN]
Subject: [ERR] [SUBJECT]

Transmit Report:

To: [USER]@[DOMAIN], 402 Local User Inbox Full ([USER]@[DOMAIN]) 64,20000,19997

Quote: From: MAILER-DAEMON@[DOMAIN-1] (Mail Delivery System)
Subject: Undelivered Mail Returned to Sender

This is the Postfix program at host [DOMAIN-1].

I'm sorry to have to inform you that your message could not
be delivered to one or more recipients. It's attached below.

For further assistance, please send mail to

If you do so, please include this problem report. You can
delete your own text from the attached returned message.

The Postfix program

<[USER]@[DOMAIN-2]>: user unknown. Command output: Invalid user specified.

This one I purposely just made to demonstrate here. All the ones above were processed by a mail server for a domain existed. This one here is how MY mail program on MY server handled an e-mail being sent to a non-existant domain name:

Quote: From: MAILER-DAEMON@[MY MAIL SERVER]
Subject: failure notice

Hi. This is the qmail-send program at [MY MAIL SERVER].
I'm afraid I wasn't able to deliver your message to the following addresses.
This is a permanent error; I've given up. Sorry it didn't work out.

<[USER]@[DOMAIN]>:
Sorry, I couldn't find any host named [DOMAIN]. (#5.1.2)

Fell free to add others that differ from these ones above. The main thing seems to be any mail coming back from POSTMASTER@ or MAILER-DAEMON@, process it, take out the e-mail addresses found in it, and compare them against e-mails that have gone out, probably unlikely you'd have multiple mathes, so first match would most likely be it.

Later on, when I get time, I will write a script to do this..

-Greg

Greg K's picture

He has: 2,145 posts

Joined: Nov 2003

Update: found out from a topic on another forum that there is a way to at least verify the domain for an email is valid using PHP (so there is probably something in ASP too)

getmxrr()

-Greg

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.