views:

22

answers:

1

Tools like BaseCamp, FogBugz & Jira have features where you can send an email to the server on a special address, and it will monitor this address and respond to mails received... e.g Jira let's you create a new bug-report by email, BaseCamp will append an email to a discussion thread, even figuring out the right thread based on the email contents.

If you had a Java web-app, how would you go about adding this functionality? A separate app which somehow polls a mailbox? A script which runs a Java app every few seconds?

What Java standard classes can be used here for the email parts? And is it mandatory that you already have a mail-server running so you can allocate an email account for the app, or do any of these apps provide their own lightweight email servers?

+1  A: 

Apache Camel could be useful for something like this. It provides an email endpoint that could be used to poll the email account. From there, Camel provides a number of endpoints that could be used to act on the email just read. For example, you could place a message on a JMS queue, call an HTTP URL, or just call one of your own classes.

scompt.com
@scompt.com Would this require a separate application, or can it be bundled into the main web-facing app somehow>
John
Also on taking a brief look, it seems very 'enterprisey'... lots of abstraction and so on. Can it be used simply and quickly to throw something together, or is there a lot of setup involved with XML hell... and can it be used directly from a standard Java app not using Spring or other frameworks?
John
You should be able to fire it up in your main app. All you need to do is create a `CamelContext`, add some routes, and `start()` it. They specifically say that it's made for such embedding.
scompt.com
It's actually not too enterprisey. You can use it with all the Spring stuff, but also very easily without. There's an example at http://fusesource.com/docs/router/1.6/deploy_guide/FMRDS.ARBCC.html that starts it from a `main` method. Put that bit somewhere in your web app and you should be set.
scompt.com
Looks very helpful, thankyou.
John