tags:

views:

308

answers:

5

I am working on an email polling solution, for a multi-user system. So users can send emails on their respective ids and it would be polled and inserted to a db.

There are two options that I am considering:

  1. Perl/Unix based email pollers..
  2. A java based poller.

What would you recommend.. (other suggestions are also welcome)

+1  A: 

Instead of polling, why don't you forward the mail to a process? Depending on the mail server you use, you can do that as an alias or even in the .forward file.

Paul Tomblin
A: 

I've nothing much to add to this, but there's currently a project at google code to rebuild iwantsandy.com as open source.

It's at:
http://code.google.com/p/sandysback/

I'm definitely going to be watching this to see how they parse emails, and have those emails "inserted into a db"

seanyboy
A: 

Whichever language you have most experience in!

I personally know java and perl well and for this task I would choose perl but the differneces are marginal.

Perl would be shorter and sweeter, java would be take longer but probably be a more robust solution once the database access is sorted out.

I find Perl DBI is a better and more portable database interface than JDBC which does not hide database implementations from your code and is sensitive to version changes etc. I.E. you must have the right version of the right database driver for your target database.

James Anderson
A: 

RE: Poling

If you have the option to forward the email to a process I would highly recommended you do that. (Forwarding generally puts less load on the server than poling does.) If not, then poling is the next best thing. Look into the POP3 client libraries on whichever language you are most comfortable with.

RE: Language choice

If I intended to do a lot of parsing of the emails then Perl would be my choice. If not much parsing is involved then Java would be the way to go for me ;-).

-- In a former life I wrote a Perl script to parse (well structured) incoming emails into HTML pages and post them to a web server.

Chris Nava
A: 

You have a couple of options. As the orginal poster said - probably the simplest way is to set up an entry in the aliases file to a script.

Then the body of the email gets passed as standard input to the script. You can then use a perl script + Mime modules to parse out the bits of the message and do whatever you want with it.

One might also look at apache james - which is a custom mail server. They have the equivilent of servlets, called 'maillets' that you put your business logic in. They often hard to deploy in enterprise scenario's though as most companies don't like having custom mailservers being deployed.

... the aliases route is probably your best bet. one other note of caution - email isn't gauranteed. if you are using this as some sort of app to app messaging system, and you control both ends, you should probably look at something else, like JMS type messaging.

-Ace

phatmanace