开发者

Detect Failed Email Send Using Gmail as a Relay

开发者 https://www.devze.com 2023-04-12 04:31 出处:网络
I wrote a simple ASP.NET application that sends mail to a specified email address (fo开发者_运维技巧r clients of the company in question, not spam =) ) and part of the requirements were that if the em

I wrote a simple ASP.NET application that sends mail to a specified email address (fo开发者_运维技巧r clients of the company in question, not spam =) ) and part of the requirements were that if the email failed to send, the application would record that. No problem, I thought, I'll just catch a SmtpFailedRecipientsException and make a note. It turns out that Gmail relays don't throw exceptions when sending to invalid email addresses, they simply accept the sent mail and then if the send failed, Gmail sends you an email back saying that mail failed to send to the recipients. My question is, if my client is using Google Business for their mail (which they are), is there any way to configure the sending so that I'll get this exception when the send fails?


One thing that comes to mind is to set up some sort of 'listener' that periodically checks the gmail inbox that would receive the bouncebacks. If you could do that, you could then parse the bounceback emails that are found and use that information to see what happened and act accordingly.

Found this article on Codeproject that walks through reading the messages in a gmail inbox. It could set you on the right track. http://www.codeproject.com/KB/applications/ReadGmailInboxMessage.aspx


No. The SMTP protocol allows for bounce messages instead of error codes in many situations, and there's no standard way (or nonstandard way, as far as I'm aware) to force a mail relay to act synchronously. Since there are many errors that can occur after the relay has accepted your message, there's no way to avoid the possibility of bounces.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号