Its a very old question, I don't know if you have got it solved.
As per MSDN: http://msdn.microsoft.com/en-us/library/swas0fwc(v=vs.100).aspx
When sending e-mail using Send to multiple recipients and the SMTP
server accepts some recipients as valid and rejects others, Send sends
e-mail to the accepted recipients and then a
SmtpFailedRecipientsException is thrown. The exception will contain a
listing of the recipients that were rejected.
This is an example of catching this exception taken from MSDN:
try {
client.Send(message);
}
catch (SmtpFailedRecipientsException ex) {
for (int i = 0; i < ex.InnerExceptions.Length; i++) {
SmtpStatusCode status = ex.InnerExceptions[i].StatusCode;
if (status == SmtpStatusCode.MailboxBusy || status == SmtpStatusCode.MailboxUnavailable) {
Console.WriteLine("Delivery failed - retrying in 5 seconds.");
System.Threading.Thread.Sleep(5000);
client.Send(message);
}
else {
Console.WriteLine("Failed to deliver message to {0}", ex.InnerExceptions[i].FailedRecipient);
}
}
}
Complete example here: http://msdn.microsoft.com/en-us/library/system.net.mail.smtpfailedrecipientsexception.aspx?cs-save-lang=1&cs-lang=csharp#code-snippet-2
Internally the Send
uses the statuscode
returned from RCPT TO
command to raise the appropriate exception.
Check the implementation for PrepareCommand
in the RecipientCommand.Send
method of smtpTransport.SendMail
(This method is called internally by SmtpClient.Send
). It uses RCPT TO
to get the StatusCode
which is then parsed in the CheckResponse
method and accordingly the SmtpFailedRecipientsException
is raised. However, VRFY and RCPT both are not very reliable because the mail servers tend to delay (throttle NDR) or swallow the response as an anti-spam measure.