.netsmtpmimemailmessageemail-bounces

Replace System.Net.Mail.MailMessage with manually created message and send it


I am trying to send emails that will bounce to a known mailbox. I plan to use VERP. Unfortunately the System.Net.Mail.MailMessage object does not allow me to precisely set the From: and Sender: headers within my email - it forces the values so that the resulting email contains the phrase 'on behalf of', and does not allow me fine control over the relevant mime headers. I therefore plan to manually write mime email messages directly to the pickup directory so that I can independently control the From and Sender headers. My dev box is a Vista box and therefore does not have an SMTP server. I would like to configure the dev box so that I have an SMTP server running on it. I can then turn off the SMTP server, write messages to the pickup dir, then turn on the SMPT server and see how the individual emails that I have written will behave (some delivered, some bounced to a bounce handler on a different email domain, as dictated by the Sender). Two questions: 1. Can anyone recommend an SMTP server that will monitor a pickup directory? 2. If I set headers as follows; From:a@a.com; Sender:b@b.com then the recipient will see the email as having come from a@a.com ( and won't see any reference to b@b.com), but if the mail bounces then the NDR will be sent to b@b.com).

It's a real pain to have to do this, but I can't see any way of using System.Net.Mail.MailMessage without it messing up my headers.


Solution

  • A nice (free) SMTP server is Mercury - it can monitor a directory and is very simple to setup and configure.