views:

760

answers:

5

Sending email is easy with commons-email, and with spring it is even easier. What about receiving incoming email? Are there easy to use APIs that allow to bounce emails, process attachments, etc.

+1  A: 

James is probably your best bet, but email handling is extremely complex, requiring not only configuration of your MTA (the James server), but also DNS. In the past, I've found it easier to initiate my handlers via hooks from non-Java MTA's like postfix. And procmail might also be useful to you. For a Java MTA though, James rocks.

jcrossley3
James is a very complex product. If you only need to receive e-mail, and don't need anything else, use SubEthaSMTP. If you don't have experience wirth James, use SubEthaSMTP and a real e-mail server (postfix) in front of it and let that handle the complex stuff.
extraneon
James is very complex, and it has little subtleties one has to be aware of while configuring its (very, very verbose) xml file. If you need a mail server in java, James will work. If you need an application mail server, SubEtha+postfix will be _much_ easier and sane.
Richard Levasseur
+1  A: 

Apache Commons Net is the perfect library to fetch mails via POP3. IMAP is not supported.

furtelwart
mmm...but then I have two constantly poll the server, right? Instead of being a server and sitting idle until email arrives...
flybywire
+1  A: 

See if Sun's own JavaMail (API docs) suits your needs.

I'm not sure about easiest, but at least it is a widely used way.

Jonik
+3  A: 

SubEthaSMTP Mail Server allows you to create your own SMTP Server for receiving emails.

Peter Štibraný
Definitely a very clean and accessible product. I have some experience with it and I can say there are not many libraries which are so easily integrated.
extraneon
A: 

Check jGuru's JavaMail tutorial here. There are ways to read and detach attachments.

n002213f