views:

64

answers:

3

I am trying to design a system that will catch emails that are submitted to a server and process them. The processing will probably mean parsing metadata such as ip addresses, the email body and subject etc., and submitting these details to a web service.

I'd like to know what software (SMTP servers or similar) can either be integrated with, to perform arbitrary processing, or which servers will support forwarding to a web service (with queuing and retrying) out of the box.

Exchange is not a preferred option, as I'd like to keep that off the live servers.

+2  A: 

It's probably easiest to just use any mail server and just process messages by pulling them directly out of the mailbox of the email user(s) on the system via IMAP or POP3 or something similar. Some mail servers are built with 3rd party access in mind where can register for events on new mail arriving so you don't have to poll for new messages. Different mail servers have different native access protocols and APIs. Exchange has IMAP and Exchange Web Services (EWS), Domino has C++/COM APIs, GroupWise a web service. And all are going to support some kind of default client access protocols like IMAP and POP3. The native protocols will give more features (like notifications), but for your purposes IMAP or POP3 may be enough.

Jeremy Raymond
A: 

It might be worth your while to implement a simple lexing/parser to parse the header and look out for a specific header information. If it is an IP address, you may get away with it by using a regex parser.

Ideally, you should connect to the POP3 port of the server where the emails are stored and do a quick scan of the information, if the subject line or the message contains a specific string indicating that it is the email or even the IP address within the header, then you can retrieve that email and process it, this is where I think the lexing/parsing of the email would be done initially prior to pulling it down based on the criteria.

Bear in mind, you do not want to pull down an email that is not relevant, then how would you deal with it.

Maybe DotNetOpenMail might help, as it does not necessarily pull down all emails...

Hope this helps, Best regards, Tom.

tommieb75
+1  A: 

Hi,

There are a ton of ways to do this. A lot of this can also depend upon price, client, and the tech environment.

If this is a MS environment, and cost is a factor, one way you can do this is to use the built in IIS SMTP Service. The IIS SMTP service is most commonly used for sending emails, however, it can be configured to actually accept email. If you configure the service for a domain, all incoming email for that domain is placed in the mailroot/drop directory. It's placed as a text file ({guid}.eml format).

You can just use a Mime parser to parse these files, and then perform any business rules you want to on them. Since this is done at the filesystem level, you won't have to worry about intercepting any network calls. Just grab a file, parse it, and move to the next file. Then, have your app sleep for X seconds, and then check to see if any new emails have come in.

Cheers!

Dave

PS: shameless plug -- you can use aspNetMime for parsing these files, and extracting the data.

dave wanta