日期:2014-05-17 浏览次数:20739 次
package util;
import org.apache.commons.mail.EmailException;
import org.apache.commons.mail.SimpleEmail;
public class EmailUtil {
public static void sendEmail(String addTo, String msg){
SimpleEmail email = new SimpleEmail();
email.setHostName("smtp.sina.com");
email.setAuthentication("账号", "密码");
email.setCharset("utf-8");
try {
email.addTo(addTo);
email.setFrom("***@sina.com");
email.setSubject("***");
email.setMsg(msg);
email.send();
} catch (EmailException e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
sendEmail("**@qq.com", "你好");
}
}