MailMessage,Sender 和 From 属性的区别 [英] MailMessage, difference between Sender and From properties
问题描述
自从我们从 .NET Framework 1.1 切换到 3.5 框架后,我就一直在使用 System.Net
命名空间,但从那以后,有一件事一直让我感到困惑.MailMessage
类中的 Sender
和 From
属性之间有什么区别?
I've been using the System.Net
namespace ever since we switched from .NET Framework 1.1 to the 3.5 framework, but there’s one thing that’s been puzzling me since. What's the difference between the Sender
and the From
properties in the MailMessage
class?
它们是否相同,如果不同,是否有理由将 Sender
与 From
一起使用?
Are they both the same, and if not is there a reason to use Sender
together with From
?
例如:
Using m As New System.Net.Mail.MailMessage()
m.Sender = New System.Net.Mail.MailAddress("test@test.com", "Name here")
m.From = New System.Net.Mail.MailAddress("test@test.com", "Name here")
m.Subject = "Test"
m.Body = "Test"
Dim client As New System.Net.Mail.SmtpClient("mymailserver.com")
client.Send(m)
End Using
推荐答案
电子邮件中的 wiki 摘录:
Excerpt from the wiki on email:
标题字段:消息头至少应包含以下字段:
Header fields: The message header should include at least the following fields:
发件人: 电子邮件地址和作者姓名(可选).在许多电子邮件客户端中,除非通过更改帐户设置,否则无法更改.
From: The e-mail address, and optionally the name of the author(s). In many e-mail clients not changeable except through changing account settings.
另请注意,发件人:"字段不必是电子邮件的真正发件人.一个原因是很容易伪造发件人:"字段并让邮件看起来来自任何邮件地址.可以对电子邮件进行数字签名,这更难伪造,但此类签名需要额外的编程,而且通常需要外部程序来验证.一些 ISP 不会中继声称来自并非由他们托管的域的电子邮件,但很少(如果有)检查以确保发件人:"字段中指定的人或什至电子邮件地址是一个与连接相关联.一些 ISP 将电子邮件身份验证系统应用于通过其 MTA 发送的电子邮件,以允许其他 MTA 检测可能来自他们的伪造垃圾邮件.
Also note that the "From:" field does not have to be the real sender of the e-mail message. One reason is that it is very easy to fake the "From:" field and let a message seem to be from any mail address. It is possible to digitally sign e-mail, which is much harder to fake, but such signatures require extra programming and often external programs to verify. Some ISPs do not relay e-mail claiming to come from a domain not hosted by them, but very few (if any) check to make sure that the person or even e-mail address named in the "From:" field is the one associated with the connection. Some ISPs apply e-mail authentication systems to e-mail being sent through their MTA to allow other MTAs to detect forged spam that might appear to come from them.
发件人:实际发件人的地址,代表发件人:字段中列出的作者(秘书、列表管理员等).
Sender: Address of the actual sender acting on behalf of the author listed in the From: field (secretary, list manager, etc.).
关于http://en.wikipedia.org/wiki/Email的详细信息
Details on http://en.wikipedia.org/wiki/Email
例如,gmail 使用发件人/发件人字段从与您的 Gmail 帐户不同的电子邮件地址发送电子邮件(验证后).
这篇关于MailMessage,Sender 和 From 属性的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!