views:

28

answers:

2

Using this:

MailMessage mm = new MailMessage();

What is the difference between:

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

Thank you

+3  A: 

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.

Michael Petrotta
Thank you very much for clering that up for me.
lucifer
+1  A: 

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.

Oded
Thank you very much for clering that up for me.
lucifer