views:

864

answers:

2

You've probably seen web apps that have an "email dropbox". Users can send email to a special address like '[email protected]' and the message will be parsed and inserted into their account as a comment, to-do, etc.

We're trying to build something like this, and wondering which way would be best? Is the '[email protected]' an actual defined email account or an alias? Or is it neither and they use a catch-all email account and then simply parse the 'To' address to determine which account to associate it with? Could it also be a defined email box called 'dropbox' and because they're using dynamic sub-domains, all of the emails are delivered to one big inbox and then parsed based on the messages 'To' address?

+1  A: 

Parsing the "To:" address definitely works, though you're going to want to look at a few others in case the email was a Bcc or something.

If you can wildcard the emails to one place, great. As it turns out, good old POP3 works great as a sort of queuing system here; in my experience, the best approach is to simply make the email address point to a POP3 account and then have a script that runs periodically on a server to check said POP3 account and parse the emails and do something with them.

You should be able to find a library for the dirty work of loading and parsing the emails in your language of choice, making this a reasonably easy task, since your webapp already has a RESTful API, right?

Jim Puls
+3  A: 

I suggest creating a catch all email address with a wild card alias for the subdomain of the account. DropBox@*.yourdomain.com

The subdomain is an alias in your mail server which points to an actual account on your email server [email protected].

Then users can send emails to something like [email protected] which will be parsed by the alias and routed to the physical email address.

Then you can create a service that pulls out all the received emails, parses the subdomain (which directly corresponds to the recipient accounts username) and parse the body of the email which is then pushed into your commenting or messaging system.

This usually works quite well and is actually really easy to implement.

Update: I started to write a 3 part series on DotNetSlackers.com to specifically address this topic. It covers the set up and configuration of the email server, the code to connect to the pop server from C#, and the processing that has to occur to handle the mail that comes in. It is wrapped up by putting all of this functionality into a windows service so that the tool works on its own (as well as logging out to the file system). Let me know if the articles don't cover something! (The first one is up now. The other two are submitted with the second one being made public 7/29/2009. The third one should be released the following week.)

http://dotnetslackers.com/articles/aspnet/Creating-a-Dynamic-Email-Drop-Box-Part1.aspx

Andrew Siemer