Bounce handling

Bounce message, also called a (failed) Delivery Status Notification (DSN) is an automated electronic email message from a mail system informing the sender about a delivery problem. The original message is said to have bounced.

Errors may occur at multiple places during email delivery. A sender may sometimes receive a bounce message from a recipient’s mail server. Bounce messages from the recipient’s mail server are required when a mail server accepted a message that was undeliverable.

You can use Mail.dll .NET email component to analyze the email message and determine if it is a bounce.

// C#

IMail email = ...;

Bounce bounce = new Bounce();
List<BounceResult> results = bounce.ExamineAll(email);

bool isDeliveryFailure = results.Count > 0;

foreach(var result in results)

    Console.WriteLine(result.Action);    // DSNAction.Failed or DSNAction.Delayed


Dim email As IMail = ...

Dim bounce As New Bounce()
Dim results As List(Of BounceResult) = bounce.ExamineAll(email)

Dim isDeliveryFailure As Boolean = results.Count > 0

For Each result As var In results

	Console.WriteLine(result.Action)	' DSNAction.Failed or DSNAction.Delayed


Mail.dll processes Multipart/Report mime parts (defined in RFC 6522) to recognize bounce messages, as well as other heuristics (X-Failed-Recipients header, subject and body scanning).

Unfortunately, most bounce messages have historically been designed to be read by users, not automatically handled by software. It’s nearly impossible to reliably interpret the meaning of every single bounce message. Bounce class handles large proportion of bounces, but it will never be 100% reliable.

You may also consider using other techniques to recognize bounces such as Variable Envelope Return Path (VERP) method.



Consider using our Q&A forum for asking questions.