简体   繁体   English

MailMessage,Sender和From属性之间的区别

[英]MailMessage, difference between Sender and From properties

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. 自从我们从.NET Framework 1.1切换到3.5框架以来,我一直在使用System.Net命名空间,但是有一件事让我感到困惑。 What's the difference between the Sender and the From properties in the MailMessage class? MailMessage类中的SenderFrom属性之间有什么区别?

Are they both the same, and if not is there a reason to use Sender together with From ? 它们是否相同,如果没有,是否有理由将SenderFrom一起使用?

For example: 例如:

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

Excerpt from the wiki on email: 摘自电子邮件中的wiki:

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. 在许多电子邮件客户端中,除非通过更改帐户设置,否则无法更改。

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. 有些ISP不会转发声称来自非托管域名的电子邮件,但很少(如果有的话)检查以确保“发件人:”字段中指定的人员甚至电子邮件地址是一个与连接相关联。 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. 一些ISP将电子邮件身份验证系统应用于通过其MTA发送的电子邮件,以允许其他MTA检测可能看起来来自他们的伪造垃圾邮件。

Sender: Address of the actual sender acting on behalf of the author listed in the From: field (secretary, list manager, etc.). 发件人:代表作者在From:字段(秘书,列表管理员等)中列出的实际发件人的地址。

Details on http://en.wikipedia.org/wiki/Email 有关http://en.wikipedia.org/wiki/Email的详细信息

For example gmail uses the from/sender fields to send emails from different email adresses than your gmail account (After verification). 例如,gmail使用from / sender字段从不同的电子邮件地址发送电子邮件,而不是gmail帐户(验证后)。

I found this explanation to be pretty easy to understand (emphasis mine). 我发现这个解释很容易理解(强调我的)。

One area in which there is quite a variety of operation is in the concept of the From Address of an email and the Sender of the email. 在电子邮件的发件人地址和电子邮件的发件人的概念中,存在各种操作的一个领域。

Some email servers will accept the From Address as being the Sender, and some deduce the Sender automatically, and some require the Sender to be specified explicitly. 某些电子邮件服务器将接收发件人地址作为发件人,有些会自动推断发件人,有些则要求明确指定发件人。

In general, the Sender is the actual originator of the email message. 通常,发件人是电子邮件的实际发起者。 The From Address, in contrast, is simply a header line in the email that may or may not be taken to mean anything. 相比之下,发件人地址只是电子邮件中的标题行,可能会也可能不会被视为任何内容。 The From Address can often be left out completely. 发件人地址通常可以完全省略。 Spammers can easily spoof the From Address. 垃圾邮件发送者可以轻松欺骗发件人地址。 ISPs try to ensure that spammers cannot spoof the Sender. ISP试图确保垃圾邮件发送者无法欺骗发件人。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM