2

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 (client@example.org), but I want to automatically handle bounces via VERP. Basically, the email From: header will be client@example.org, 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?

josh3736
  • 139,160
  • 33
  • 216
  • 263
  • Hi Josh were you able to find out how to solve this? Thanks – Diego Ramos Jun 06 '22 at 19:06
  • @DiegoRamos: I did, but unfortunately, this was 10 years ago, so my memory is fuzzy. I believe I had to use some other SMTP implementation that actually supported VERP, but I don't recall what exactly I used. – josh3736 Jul 07 '22 at 01:10

1 Answers1

0

System.Net.Mail.SmtpClient internally is using mailMessage.Sender ?? mailMessage.From for the envelope MAIL FROM envelope sender.

Unfortunately while you could use the Sender property to specify a envelope MAIL FROM envelope sender using the mailMessage.Sender property, SmtpClient will also add a Sender: unique-email-id@domain.com header.

With this Sender header, the email client then shows a send from unique-email-id@domain.com on behalf of John Doe <doe@domain.com>

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?

Martin Meixger
  • 2,547
  • 24
  • 26