Question

I’m currently working on an web application that sends emails. Actions taken place by a user in the browser create events which are passed to a secondary server which sends emails to users who have subscribed to these events.

The current implementation for sending emails is basically a home grown SMTP server. I think it was ported to C# from legacy system and it’s quite unreliable.

My requirements are to be able to send messages and also to know the delivery status of the messages. If they’re failing I’d like to know why and whether or not they’re in the process of retrying.

Ideally, I’d like to scrap the home grown SMTP server and use an open source solution. I know that I can run an SMTP server (like hMailServer) on a machine and use .NET’s SmtpClient to connect and send messages. By itself, this isn’t going to give me much insight into the status of the messages.

It looks like with hMailServer you can use the COM API to query the server and get message statuses. Is this possible? Is this a valid approach?

Aside from what I’ve outlined above, are there any other options?

Thanks!

Was it helpful?

Solution

What you're asking for isn't feasible in its entirety. (Parts of what you're asking are feasible.)

An Email goes through several servers in between the sender and the recipient, and you can only control some of them. The rest are completely out of your control.

You CAN capture many of the send failures, but if a third party spam blocker blocks your email before it reaches the recipient, you have no control over how that spam blocker works. You can't guarantee it will return a reason.

As an alternative, you could catch the errors that are possible (via hMailServer, for example) to get and above that, do what email marketers do: Track email opens to see which emails are being read. This is different than being delivered, obviously.

There's more on how to do this with .NET here: http://www.codeproject.com/Articles/15109/Tracking-Emails-for-Open-Read

From our experience, we used a commercial software named Campaign Enterprise from Arial Software, which offers the ability to track just about everything you're asking for, and uses the "email open" techniques described. It worked quite well, but it's not free.

There may be other alternatives out there, but that would be a product recommendation question and would be off-topic here. I offer the above solely as a starting point for you to do your own research to see what other products exists, including those within your price range. (Although this one looks like it might be good, and free.)


Added based on comment below:

Other options for attempting to trace trappable SMTP Transmission errors.

If all you want to know is errors from the SMTP session, you can use the built-in .NET tools, and grab the session trace as outlines here:

http://www.systemnetmail.com/faq/4.10.aspx

You can also grab the SmtpFailedRecipientsException if it occurs. Documentation with code sample available at MSDN.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top