kala-tamin IIS SMTP Message Inspection

IIS SMTP Message Inspection

Is there a way to peek or see a message before it hits the SMTP on IIS. This is not an Exchange Server, it's just running SMTP. I am trying to see if I can look at the message and then pass it to SMTP?


Edit ~ Instead of adding another listner, I am wondering if there is a way to bind to the default SMTP listner and intercept the message then pass it on.

2nd Edit~ Ok, here is my problem. I have a spam filter in front of my exchange box, unfortunately (due to software design) the filter is limited when it comes to "Directory Harvesting Loookup". This is the process where the email addresses are checked if they exists in AD and the mail is dropped if they don't. My current filter drops the mail if one of the addresses does not exists in AD which is not good. I spoke with the vendor and there is nothing they can do at this time. I am looking put an app in front of this filter which would intercept (open, read, parse) the mail, validate the addresses, and then pass on the email to the filter for additional scanning. I'll then trun off this feature in their software. Don't get me wrong, their filter works great with this one exception which I must fix since I have tons of emails send to nonexistent users in my domain.

detecting the presence and version of IIS using MSBuild


How to create a job in IIS capable of running an extended process
You can write your own Proxy SMTP service that you connect to to send messages.

File Security (IP address access restrictions) in IIS7
You can forward all messages directly to your actual SMTP service and pass all responses back.

Windows IIS test server setup
Then you can evesdrop on all these messages and deal with them accordingly..
How to configure multiple intranet website on server 2003?
Might be a bit overkill for what you're after but it's fairly simple to code as you dont need to know anything about the protocol as all you're being is a proxy..
Dojo load time extremely slow on iis

bypass IIS xml file settings at file/folder level

Creating IIS Instance over network using MSBuild


If you're using .NET 2.0 then you can log SMTP sessions to a file:. How do I create a log file of the SMTP session? (System.Net.Mail). Updated:. Take a look at this question:. Testing SMTP with .net (Stack Overflow). From your edit: . "I am wondering if there is a way to bind to the default SMTP listener and intercept the message then pass it on?". ...and from your comment below:. "I am looking to inspect the actual message before the SMTP gets it.". I'm not sure if you fully understand the SMTP protocol.

SMTP messages aren't just monolithic fire-and-forget entities.

SMTP is session based and there is a conversation between client and server, of which, the message is just a part.

The tracing method (linked to above) will record the entire exchange between client and server and does intercept the whole message before passing it on.

The alternative, a proxy or mock server, will still require your application to engage in the SMTP client/server exchange.

The closest solution to your requirement would be to use something like Papercut which is linked to in the answer above.

. Kev.


In .Net you can tell the SmtpClient to send email to a different folder than the SMTP service is monitoring.

That way you could check each message, then move it to the real pickup folder.

(See SmtpClient.PickupDirectory).


IIRC, you can still write up event sinks for the IIS SMTP service (even though it's not full blown exchange).

It's been many years since I've done this, but you may want to google for "exchange event sink" to see if that helps..


Seems like a something like Ethereal will let you accomplish the sniffing portion of your request.

Its not clear to me what you mean by "intercept" and "pass on".

Do you want to filter some traffic or just delay traffic long enough for you to inspect before you pass it on, or both? .

51 out of 100 based on 36 user ratings 461 reviews