Simple Java Mail 1.9 is now available in Maven Central
PDFI hadn’t gotten around to putting Simple Java Mail into Maven Central due to the complexities of going through Sonatype first. But now it is done: Simple Java Mail v1.9 now resides in Maven Central and can be included in your project using the following dependency:
1 2 3 4 5 | <dependency> <groupId>org.codemonkey.simplejavamail</groupId> <artifactId>simple-java-mail</artifactId> <version>1.9.1</version> </dependency> |
Speaking of which, v1.9 was recently released with the following changes (in addition to Maven support, making it 1.9.1):
- added support for JavaMail’s reply-to address
- made port optional as to support port defaulting based on protocol
- added transport strategy default in the createSession method (solving potential NullPointerException)
- tightened up thrown exceptions (MailException? instead of RuntimeException?)
- added and fixed JavaDoc
Here’s a small example of the reply-to addition:
1 2 3 4 5 6 7 8 | Email email = new Email(); email.setFromAddress("lollypop", "lol.pop@somemail.com"); email.setReplyToAddress("lollypop's mom", "lol.mom@somemail.com"); // <-- this is it email.addRecipient("C.Cane", "candycane@candyshop.org", RecipientType.TO); email.setTextHTML("<b>We should meet up!</b>"); email.setSubject("let's meet!"); new Mailer("smtp.host.com", 25, "username", "password").sendMail(email); |