Development
JAVA|자바로 메일 보내기(Apache Commons Email)
어느가을빛
2012. 3. 20. 13:34
Apache Commons Email
* website: http://commons.apache.org/email/
* wiki: http://wiki.apache.org/commons/Email
* api: http://commons.apache.org/email/api-release/index.html
* website: http://commons.apache.org/email/
* wiki: http://wiki.apache.org/commons/Email
* api: http://commons.apache.org/email/api-release/index.html
Commons Email aims to provide a API for sending email. It is built on top of the Java Mail API, which it aims to simplify.
Some of the mail classes that are provided are as follows:
* SimpleEmail - This class is used to send basic text based emails.
* MultiPartEmail - This class is used to send multipart messages. This allows a text message with attachments either inline or attached.
* HtmlEmail - This class is used to send HTML formatted emails. It has all of the capabilities as MultiPartEmail allowing attachments to be easily added. It also supports embedded images.
* EmailAttachment - This is a simple container class to allow for easy handling of attachments. It is for use with instances of MultiPartEmail and HtmlEmail.
A simple text email
Email email = new SimpleEmail(); email.setHostName("smtp.gmail.com"); email.setSmtpPort(587); email.setAuthenticator(new DefaultAuthenticator("username", "password")); email.setTLS(true); email.setFrom("user@gmail.com"); email.setSubject("TestMail"); email.setMsg("This is a test mail ... :-)"); email.addTo("foo@bar.com");email.send();
#참조
1) http://commons.apache.org/email/userguide.html
2) http://javacan.tistory.com/entry/117
3) javax.mail Library 사용 예제: http://www.okjsp.pe.kr/seq/186937
2) http://javacan.tistory.com/entry/117
3) javax.mail Library 사용 예제: http://www.okjsp.pe.kr/seq/186937