I'm thinking about the architecture of a system which should handle incoming mails and pass it to a rails app which processes the incoming mails. I'm not sure whats the best way to do something like that.
It should work like this:
- Mails are send to something like contact@user_id.myapp.com
- The mailserver accepts the mails and passes them on to the rails app (or stores them and the rails app fetches them)
- The rails app processes the mails (some analyzing then throws them in the db)
It should basically work like a queque. Sudden peaks in mail traffic shouldn't kill the rails app.
I'm not looking for a complete solution. I'm just interested in your opinion. I figured 3 possible options:
- Rails connects via Pop3 to the mailserver and just downloads the messages (probably slow)
- The mailserver pipes the mails with a POST request to the rails APP (probably also too slow, could kill the webserver when encountering a mailbomb)
- The maildir is virtually linked into the rails app server's filesystem (mailserver and app server have to be separate) and rails just reads directly from that.
What do you think is the best approach performance- and security-wise? Am I missing something here? Is there a better way? Do you now some best practice resources?