开发者

MailMessage Question/Confusion

Using this:

MailMessage mm = new MailMessage();

What is the difference between:

mm.Sender = sender; and mm.From = from; ?

Tha开发者_如何转开发nk you


The Sender property sets the value of the "Sender" email header, where the From property sets the value of the "From" email header.

The Sender field in an email message is meant to record the actual sender of the email. Many ISPs will attempt to validate that the value for this field is correct. In contrast, no validation is done on the From field. The Sender field is not common.

Note that both of these are distinct from the "Reply-To" field, which is used to indicate where replies should be sent. It's meant to override the From or Sender fields when replying.


The Sender property sets the Sender header. There can only be one email address on it, and if the From address has more than one email address, this header has to exist.

The From property sets the From header. It can have multiple email addresses.

See RFC 5322 (section 3.6.2):

The originator fields of a message consist of the from field, the sender field (when applicable), and optionally the reply-to field. The from field consists of the field name "From" and a comma- separated list of one or more mailbox specifications. If the from field contains more than one mailbox specification in the mailbox- list, then the sender field, containing the field name "Sender" and a single mailbox specification, MUST appear in the message.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜