如何使用System.Net.Mail设置退回邮件地址?

发布于 2024-08-17 16:56:59 字数 1367 浏览 3 评论 0原文

我正在尝试实现 可变信封返回路径 (VERP) 方法来管理电子邮件地址(即,当我发送的电子邮件被退回时,我希望将其发送到特定的电子邮件地址,以便我可以更新我的数据库,以避免将来向该电子邮件地址发送电子邮件)。

根据这篇文章,可以指定退回电子邮件发送到的电子邮件地址。在 .Net 中如何做到这一点?

例如,假设我([email protected])想要发送电子邮件至您([电子邮件受保护])。如果 [email protected] 不再存在,我希望您的服务器发送将电子邮件退回至 [电子邮件;受保护])。这样,当我收到这封退回的电子邮件时,我就知道[电子邮件受保护]不再是有效的电子邮件地址,我可以相应地更新我的数据库。

在此示例中,退回邮件地址为:[电子邮件受保护]
如何使用 System.Net.Mail 指定它?

I'm trying to implement the Variable envelope return path (VERP) method to manage email addresses (ie when an email I send bounces back I want it to be sent to a specific email address so that I can update my database to avoid sending emails to that email address in the future).

According to this article it is possible to specify the email address a bounce email is sent to. How do you do this in .Net?

For example say I ([email protected]) want to send an email to you ([email protected]). If [email protected] doesn't exist anymore I want yourserver to send the bounce email to [email protected]). This way when I receive this bounced email I know that [email protected] is not a valid email address anymore and I can update my database accordingly.

In this example, the bounce address would be: [email protected]
How do you specify it using System.Net.Mail?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

荭秂 2024-08-24 16:57:00

最重要的是,您无法在 .NET 中执行此操作。您只能设置发件人地址,System.Net.Mail 也将使用该地址作为信封发件人。

要执行此类操作,您需要使用第 3 方 SMTP 对象,如我编写的对象:

http://www.aspnetemail.com aspnetemail.com

在 aspNetEmail 中,您可以执行以下操作:

EmailMessage msg = new EmailMessage();
msg.ReversePath = "[email protected]

aspNetEmail 将在 SMTP 会话期间使用 MAIL FROM 命令中的 ReversePath 值。我可以轻松地将此属性称为“ReturnPath”或“EnvelopeFrom”。回想起来,EnvelopeFrom 会是一个更好的名字。

The bottom line is that you cannot do this in .NET. You can only set the FROM address, which System.Net.Mail will also use as the Envelope-From.

To do something like this, you would need to use a 3rd party SMTP object like the one I wrote:

http://www.aspnetemail.com

In aspNetEmail, you can do something like:

EmailMessage msg = new EmailMessage();
msg.ReversePath = "[email protected]

aspNetEmail will use the ReversePath value in the MAIL FROM command during the SMTP Session. I could have easily of called this property "ReturnPath" or "EnvelopeFrom". In retrospect, EnvelopeFrom would have been a better name.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文