How do I track whether a email was successful among thousands (IIS 6, .NET 3.5)

Solution 1:

Some background:
A properly configured server should tell you imediately if the mail will not be delivered.

iirc: Originally SMTP servers did this, but then it was considered a security hole to reveal if an user exists on the system or not so they started accepting all and then bouncing. But bouncing is used by spammers to deliver spam by "bouncing it back to the spam target". So now we are back at declining the email immediately based on relay rules.

This means that in most cases you can determine if the email was delivered or not. But only if you communicate directly with the receivers email server. This means that your application needs to do a lot of work: MX-lookup, TCP connect to a potential slow server which could use tarpit so its damn slow, handle timeout, etc. The problem is that you will not handle servers that are temporarily down very well.

If you send the email by delivering it to a relay server (like your local IIS SMTP server or your ISP) then the only way to detect bounces is by setting bounce header in the mail and checking the bounce account for bounced mails. This is not an uncommon aproach. It can however take up to (and over) 5 days for all bounces to come back depending on retry settings on the SMTP-servers down the chain.

This problem is often solved by simply adding url to an image inside the message. When the user clicks "download content" the image is downloaded and you can confirm receive. The image could be http://server.com/[email protected] or it could be an aspx-page you make that uses Response.SendFile to send an image (you may want to set Content-Type in Response.Header too).

Solution 2:

The only way that I know of is to bypass IIS's SMTP server and send it directly. You can google around and find some components that will do it for you, otherewise here's a link for a raw TCP version:

This of course doesn't mean that the message was received/delivered or that it didn't bounce. It just means the SMTP listed in the MX records accepted the message. It might have trashed it, it might bounce it later, it might pass it on to the user.