使用 Gmail 作为中继检测失败的电子邮件发送
我编写了一个简单的 ASP.NET 应用程序,它将邮件发送到指定的电子邮件地址(针对相关公司的客户,而不是垃圾邮件 =) ),部分要求是如果电子邮件发送失败,应用程序将记录该情况。没问题,我想,我只需捕获 SmtpFailedRecipientsException 并做个记录即可。事实证明,Gmail 中继在发送到无效电子邮件地址时不会抛出异常,它们只是接受已发送的邮件,然后如果发送失败,Gmail 会向您发送一封电子邮件,说明邮件无法发送给收件人。我的问题是,如果我的客户使用 Google Business 发送邮件(确实如此),是否有任何方法可以配置发送,以便在发送失败时我会收到此异常?
I wrote a simple ASP.NET application that sends mail to a specified email address (for 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我想到的一件事是设置某种“监听器”,定期检查接收退回邮件的 Gmail 收件箱。如果您能做到这一点,您就可以解析找到的退回电子邮件,并使用该信息来查看发生的情况并采取相应的行动。
在 Codeproject 上找到了这篇文章,该文章介绍了如何阅读 gmail 收件箱中的消息。它可以让你走上正轨。 http://www.codeproject.com/KB/applications/ReadGmailInboxMessage.aspx
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
不可以。在许多情况下,SMTP 协议允许退回邮件而不是错误代码,并且没有标准方法(或据我所知是非标准方法)来强制邮件中继同步操作。由于中继接受您的消息后可能会发生许多错误,因此无法避免退回的可能性。
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.