如何设置SMTP信封邮件使用System.Net.Mail? [英] How can you set the SMTP envelope MAIL FROM using System.Net.Mail?

查看:570
本文介绍了如何设置SMTP信封邮件使用System.Net.Mail?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当您使用C#和System.Net.Mail命名空间发送电子邮件,可以设置从MailMessage对象和发件人的属性,但是这些都可以让你做的MAIL FROM和从地址进入彼此不同的数据部分。 MAIL FROM被设置为从属性值,如果设置发件人,它只会增加在数据段的另一头字段。这将导致从X@Y.COM代表A@B.COM的,这是不是你想要的。我失去了一些东西?

When you send an email using C# and the System.Net.Mail namespace, you can set the "From" and "Sender" properties on the MailMessage object, but neither of these allows you to make the MAIL FROM and the from address that goes into the DATA section different from each other. MAIL FROM gets set to the "From" property value, and if you set "Sender" it only adds another header field in the DATA section. This results in "From X@Y.COM on behalf of A@B.COM", which is not what you want. Am I missing something?

用例是控制NDR目的地通讯等,发送代表别人。

The use case is controlling the NDR destination for newsletters, etc., that are sent on behalf of someone else.

我目前使用而不是System.Net.Mail aspNetEmail,因为它可以让我正确地做到这一点(像大多数其他SMTP库)。与aspNetEmail,这是使用EmailMessage.ReversePath属性来实现的。

I am currently using aspNetEmail instead of System.Net.Mail, since it allows me to do this properly (like most other SMTP libraries). With aspNetEmail, this is accomplished using the EmailMessage.ReversePath property.

推荐答案

MailMessage.Sender 将始终插入发件人头(除preTED为代表的在你的电子邮件客户端)。

MailMessage.Sender will always insert a Sender header (interpreted as on behalf of in your e-mail client).

如果您使用了网​​络交付方式的 SmtpClient .Sender 也将改变发送者信封。使用 PickupDirectoryFromIis 交付方法将它留给IIS来确定信封发件人和IIS将使用地址,不是发件人地址。

If you use the Network delivery method on the SmtpClient, .Sender will also change the sender in the envelope. Using the PickupDirectoryFromIis delivery method will leave it to IIS to determine the envelope sender, and IIS will use the From address, not the Sender address.

<一个href="http://social.msdn.microsoft.com/Forums/en-US/ncl/thread/a26c273a-18eb-4143-8631-233088977b21/">There's MSDN这里就类似的问题。

这篇关于如何设置SMTP信封邮件使用System.Net.Mail?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆