I'm writing a server that will send email to many recipients on behalf of my client.
The email must come from the client's email address ([email protected]), but I want to automatically handle bounces via VERP. Basically, the email From:
header will be [email protected], but the SMTP envelope sender (MAIL FROM
) will be unique-email-id@my-email-service.example.com.
I've already built a multi-threaded sending engine that uses the built-in System.Net.Mail.SmtpClient
to actually speak SMTP with the recipient's MX server.
Unfortunately, SmtpClient
does not allow you to specify the envelope sender – it just uses the From:
address.
I need an alternative that allows me to specify the SMTP MAIL FROM
. Preferably, something that takes little work to drop in and replace SmtpClient
.
Thus far, everything I've looked at is an entire email suite (SMTP/POP3/IMAP/kitchen sink). What lightweight SMTP libraries are available?
System.Net.Mail.SmtpClient
internally is usingmailMessage.Sender ?? mailMessage.From
for the envelopeMAIL FROM
envelope sender.Unfortunately while you could use the Sender property to specify a envelope
MAIL FROM
envelope sender using themailMessage.Sender
property, SmtpClient will also add aSender: [email protected]
header.With this Sender header, the email client then shows a send from
[email protected] on behalf of John Doe <[email protected]>
I found no decent open source Smtp library supporting this – even Mono's SmtpClient lacks this feature. Some libraries supporting VERP:
PS: feel free to vote for the VERP feature request: http://visualstudio.uservoice.com/forums/121579-visual-studio/suggestions/3800792-smtpclient-should-allow-to-specify-the-envelope-se
related question: How can I implement VERP (Variable envelope return path) in .NET?