tags:

views:

146

answers:

3

I am using System.Net.Mail to to send mail. I do not know the type/version of the SMTP relay that it will connect to.

Some errors will result in no email being sent (e.g. no addresses or invalid from address) whilst others errors will still result in an email being sent.

E.g. Send To : [email protected] CC: [email protected] and [email protected] may result in an error of

The server response was: 550 #5.1.0 Address rejected [email protected].

But the email still appears to be delivered to Bob and Fred.

Is there any reference to which error codes will still result in an email being delivered or any programmatic way of determining this?

+1  A: 

RFC 821 is the one that describes SMTP and includes information about different types of errors, but not sure if it contains the details you're looking for. And either way, even if you can find out that the mail server accepted the email for some users, that is not the same as saying that it was delivered to them.

As far as I know, there is no way of telling if an email has been delivered except if the recipients mail client will tell you in some way.

ho1
Good point re: actually delivered - but what I am after is "was the email rejected in entirety" or "a problem but MTA will still attempt to deliver for some users"
Ryan
+1  A: 

This is the way that SMTP operates, as described in the RFC. Failure to deliver to one recipient does not affect delivery to other recipients.

Generically, codes starting with 4 and 5 are failures, codes starting with 2 are success codes - see RFC821 section "4.2.2. NUMERIC ORDER LIST OF REPLY CODES".

"Email being delivered" is hard to define. Email being accepted for delivery by the SMTP server is defined by the SMTP protocol (and the server will signal acceptance to deliver a message) but this server might just relay the message to another server, or operate in a smart host configuration where it just accepts messages and passes them on to the smart host - delivery is another thing and it's usually associated with local delivery (LMTP).

Some mail clients work around this problem of not being able to tell if a message has been delivered by implementing the dreaded read receipts - but this implementation is entirely on the client side and AFAIK it has nothing to to with SMTP.

diciu
"This is the way that SMTP operates, as described in the RFC. Failure to deliver to one recipient does not affect delivery to other recipients." I couldn't find that in RFC821, what am I missing.
Ryan
Oh - and when I say "Email being delivered" yes you're right its really "email being accepted for delivery" and I am fine with that.
Ryan
@Ryan: regarding your comment-question above, I think if you search the RFC for the string "The second step in the procedure is the RCPT command." and a little under that it says: *This second step of the procedure can be repeated any number of times.*. So even though you're sending one email to multiple rcpts, internally it will add the email addresses one by one to the rcpt list and give result 250 or 550 for each one. So problems with one won't affect another (as I understand it).
ho1
Acceptance for delivery is a 250 response code after the mail client writes the email body with the "DATA" command - actual text depends on implementation but the SMTP server I use says: "250 Ok: queued as QUEUE_NUMBER_HERE".
diciu
Found this great article - http://leedumond.com/blog/retrying-mail-operations-in-net/So you can use SmtpFailedRecipientsException to find out details of each individual failed recipient.http://msdn.microsoft.com/en-us/library/system.net.mail.smtpfailedrecipientsexception(v=VS.100).aspx
Ryan
A: 

Non-delivery reports (NDRs) are system messages that report the delivery status of a message to the sender. The messages are a subclass of a general message information structure that is referred to as delivery status notifications. Delivery status notifications describe three different types of situations:

* Success (2.X.X numeric codes)
* Persistent transient failure (4.X.X numeric codes)
* Permanent failures (5.X.X numeric codes)

To learn more about delivery status notifications, see Request for Comment (RFC) 1891 and RFC 1893.

Qouted from Microsoft Support http://support.microsoft.com/kb/284204

renjucool
Didn't answer the question.
Ryan