3
votes

In SMTP there is the envelope MAIL FROM header (actually an SMTP command), and a FROM header in the message data itself (example below)
I need to be able to modify the MAIL FROM header without affecting the MIME 'From' header.
The difficulty is the .net MailMessage contains one 'From' property that controls both SMTP and MIME header, and the 'Headers' attribute that allows customizing header doesn't not allow overwriting the From header.

This functionality is required for bounce tracking, and I would very much like to avoid switching to a different SMTP package or implementing SMTP from scratch...

For example - please notice the two emphasized lines

*{S}220 workstation1 Microsoft ESMTP MAIL Service
{C}HELO workstation1
{S}250 workstation1 Hello [127.0.0.1]
{C}MAIL FROM: [email protected]
{S}250 2.1.0 [email protected] OK
{C}RCPT TO:
{S}250 2.1.5 [email protected]
{C}DATA
{S}354 Start mail input; end with .
{C}
From: [email protected]
To:
Subject: Super simple email
Reply-To:
This is a very simple body.
.
{S}250 Queued mail for delivery
{C}QUIT
{S}221 Service closing transmission channel*

1

1 Answers

2
votes

Set the Sender property with the address you want in the MAIL FROM header.