Can anyone suggest a library for sending emails in Java?
+5
A:
Spring has a mail wrapper layer as well:
http://static.springframework.org/spring/docs/2.5.6/reference/mail.html
Nathan Feger
2009-05-11 15:34:26
+9
A:
Try Commons Mail. This builds on the Java Mail API but makes it much more simple to use.
Aaron Digulla
2009-05-11 15:34:59
hey will common mail with work with gmail smtp server?
2009-05-11 15:42:19
It works with any smtp server, just like any mail client.
Valentin Rocher
2009-05-11 15:44:30
+4
A:
You may also want to take a look at the Apache Commons Email library. It is featureful and easy to use.
You could do something along the lines of:
import org.apache.commons.mail.SimpleEmail;
...
String[] recipients = {"[email protected]", "[email protected]"};
SimpleEmail email = new SimpleEmail();
email.setHostName("mail.myserver.com");
for (int i = 0; i < recipients.length; i++)
{
email.addTo(recipients[i]);
}
email.setFrom("[email protected]", "Me");
email.setSubject("Test message");
email.setMsg("This is a simple test of commons-email");
email.send();
The sample code is taken from the Commons Email example page, modified to show adding multiple recipients. Hope that helps.
Paul Kuykendall
2009-05-11 15:35:26
you need to authenticate properly, but when that is done, you can use it with gmail
Thorbjørn Ravn Andersen
2009-05-12 07:15:04