package com.cc.mail;
import java.util.Date;
import org.apache.commons.mail.EmailException;
import org.apache.commons.mail.SimpleEmail;
public class SimpleMailTest {
public static void main(String[] args) throws EmailException {
SimpleEmail email = new SimpleEmail();
//设置发送主机的服务器地址
email.setHostName("smtp.qq.com");
//设置收件人邮箱
email.addTo("642294558@qq.com");
//发件人邮箱
email.setFrom("642294558@qq.com");
email.setAuthentication("642294558@qq.com", "1111111111");
//设置邮件的主题
email.setSubject("Hello, This is My First Email Application");
//邮件正文消息
email.setMsg("I am cc, This is JavaMail Application");
email.send();
System.out.println("The SimpleEmail send sucessful!!!");
}
}