Commons email
November 3rd, 2009
No comments
There are many apache commons projects out there that save your time either directly or indirectly. Some of the well known commons projects are
- Commons beanutils – Services wrapped around java beans.
- Commons digester – XML to java mappings
- Commons lang – Helper utilities for the java.lang API
- Commons logging – A generic logging implementation
There are other commons implementations that can save your time, but you are probably not using them. One of them is commons email. Commons email provides a facade to the underlying java mail services that come from mail.jar. Sending an email using mail.jar is not that difficult, but when you use commons email it is downright simple
Check out a sample program that sends a simple email
SimpleEmail email = new SimpleEmail(); email.setHostName("mail.myserver.com"); email.addTo("jdoe@somewhere.org", "John Doe"); email.setFrom("me@apache.org", "Me"); email.setSubject("Test message"); email.setMsg("This is a simple test of commons-email"); email.send();
Thats it. Use the HTMLEmail class to send HTML based emails. You can read more about the commons email API from their user guide. The project is active and should simplify the parts of your application that send email.