tags:

views:

118

answers:

3

Hi Guys,

I want my Java application to send out emails to users. But I cant get a good solution.

Now, I got some on Google but they use a SMTP server which I dont have. I was wondering if setting up one on my Linux machine would be easy?

So, I am using mailx now to send out emails but it sends emails from root which is definately not good. Is there any way to send out emails from a proper email using java? like you can do in php and other languages?

+6  A: 

Use commons-email to send email from java in a simple, straightforward way (see the docs).

You need an SMTP server always - even in "php and other languages", but perhaps you don't know you need it, because it is bundled in your LAMP package.

One solution is to use google as an SMTP server. Either via your account, or via google apps. Otherwise setting up an smtp server (postfix for example) linux appears trivial, but isn't - you have to take into consideration many things - see this post by Jeff Atwood.

So ultimately, I'd suggest using the options provided by google.

Bozho
A: 

if you'r looking to host your own mail server, then apache james is a pretty good option.

or other solution could be using a third-party mailservers such as gmail or yahoo; and use the JavaMail API to send emails.

phoenix24
A: 

If you don't have an SMTP server, Asprin is a send-only SMTP server, which is a pretty good fit. It suffers from the same problem any do-it-yourself SMTP server will, in that it will look more like a Spam source, so using a proper SMTP server used for e-mail should be done if possible.

Yishai