preload
Dez 14

To send simple mails im Java, e.g. without header modifications or attachment you can use apache commons library.

Download it at http://commons.apache.org/ and add the jar to your project.

1
2
3
4
5
6
7
8
9
SimpleEmail email = new SimpleEmail();
email.setHostName("host.test.com");
email.setFrom("from@test.com", "testfromname");
email.addTo("to@test.com", "testtoname");
email.addBcc("bcc@test.com", "testbccname");
email.setSubject("testsubject");
email.setMsg("testmessage");
email.setAuthentication("username", "pass");
email.send();

Check simple email-class documentation for further configuration as smtp-port etc.

Tagged with: