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 thecapabilities 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 ofattachments. It is for use with instances of MultiPartEmail andHtmlEmail.
2.下面两个经过测试的代码:
//发送简单的文本 import org.apache.commons.mail.EmailException; import org.apache.commons.mail.HtmlEmail;