MailMessage, difference between Sender and From properties
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
In System.Net.Mail.MailMessage, From and Sender are related but not identical. From describes the authoring address of the message, while Sender is used when the message is actually being sent by a different mailbox on behalf of that author.
Use From as the Primary Author Address
From is the address most recipients think of as "who the message is from." It is the main mailbox associated with the message content.
In this example, the recipient sees the message as coming from the Billing Team. If you stop here and do not set Sender, the From address is both the visible author and the effective sending identity represented by the message headers.
Use Sender for "On Behalf Of" Scenarios
Sender matters when one mailbox or system sends mail on behalf of another. A common example is an automated service or delegated assistant sending a message that should still appear to come from a team mailbox.
Here, From says the message is from the Sales Team, but Sender says the actual sending agent is the notification service. Some mail clients expose this as wording similar to "sent on behalf of."
This distinction is useful when:
- A service account delivers mail for a shared mailbox
- An assistant sends mail on behalf of an executive
- Infrastructure sends messages for an application identity that users should recognize
Keep ReplyToList Separate in Your Design
Developers sometimes confuse Sender with the place replies should go. That is a different concern. If you want replies to land somewhere else, use ReplyToList.
In this case, the message still comes from [email protected], but replies are directed to support. That is independent of whether Sender is set.
Think in Terms of Email Headers
A useful mental model is:
- '
From: the mailbox the message claims to be authored by' - '
Sender: the mailbox that actually sent it when different' - '
ReplyToList: the mailbox that should receive replies'
Those are separate pieces of metadata, and using the correct property makes your intent clear both to mail systems and to other developers reading the code.
Common Pitfalls
The most common mistake is setting Sender when ReplyToList was actually intended. If your goal is "reply somewhere else," then Sender is the wrong tool.
Another issue is expecting every mail client to display Sender prominently. Many clients emphasize From and only reveal sender details when they differ or when the user expands the full headers. The header is still meaningful even if the UI does not always surface it.
It is also easy to forget that your SMTP infrastructure must allow the chosen combination of addresses. If you set From to one domain and the actual sending account is not authorized to send on its behalf, the message can be rejected or flagged by mail authentication checks.
Finally, avoid setting both properties without a reason. If there is no delegated or on-behalf-of scenario, keeping only From makes the message simpler and easier to understand.
Summary
- '
Fromis the primary author identity of the email.' - '
Senderis used when a different mailbox or service sends the message on behalf ofFrom.' - '
ReplyToListcontrols where replies go and is not the same asSender.' - Some email clients display
Senderas an "on behalf of" detail when it differs fromFrom. - Use
Senderonly when delegation or delivery indirection is part of the design.

