Reputation: 207
I need advice on processing/tracking bounce emails. We have a scenario, where we need to send emails to recipient on behalf of our customers. lets say we need to send email to [email protected] with from as [email protected] but when this email fails we need to receive the bounce/failure notification on [email protected]
I tried using the reply-to/return-path but both getting replaced with [email protected]. We were not able to process bounce message as we dont own the inbox for [email protected].
Please help!!..
We created smtp client on C#.net
Upvotes: 1
Views: 1089
Reputation:
Please be advised that we can't rely on the reply-to headers or inserting a custom ID to our original message's headers since the bounced messages returned by the mail servers vary from server to server. Many of them just bounced with a plain-text saying that the delivery is failed without including the original message.
My advise is to use Regex with compiled options (for performance) to scan the messages.
After you have read the message content, you can use the following code to classify a message as a soft bounce that states that the message sending was failed:
string pattern = "failed after \S+ sent[\s\n]the[\s\n]message";
Regex regexPattern = new Regex(pattern, RegexOptions.Compiled);
if (regexPattern.Match(myMessage.BodyHtml))
{
Console.WriteLine("This is a soft bounce");
}
You can add more patterns to classify more messages.
Upvotes: 1