Search code examples
javaemailpostfix-mta

Send email in via Java using Postfix


I am currently developing a web application based on Java EE, JSF, EJB etc. This application is deployd on a Debian 7.6 and there is Postfix installed.

I can use something like this to send emails via commandline:

/usr/bin/mailx -s "SUBJECT" -a "From: from@email.de" to@email.de

This is working so far.

My attempt is, to use this line and run it as linux command in Java. Is that correct?

Can I use JavaMail for this (send email via postfix) and if so, how can I set up the config for this?

I am really struggeling with this part of my webapplication. Maybe you can help me to find out, what the best solution is.


Solution

  • I don't think using ProcessBuiler and running executable commands for sending emails is called for, when JavaMail has already provided an API for mail (sending/receiving) clients such as your webapp. Assuming you have set up a mail server like SMTP, you can follow a tutorial like this to do this more seamlessly.