最简单的发送邮件方法
package com.omg.web.util;
import org.apache.commons.mail.SimpleEmail;
public class SendEmail {
private static String smtp="smtp.163.com";
private static String encoding="GBK";
private static String title="find your password";
private static String sendemail="
[email protected]";
private static String sendpassword="******";//密码我就不公布了。。。
public static void sendemail(String ue,String p) throws Exception {
SimpleEmail email = new SimpleEmail();
email.setTLS(true);
email.setHostName(smtp);
email.setAuthentication(sendemail, sendpassword); // 发送方的邮箱和密码
email.addTo(ue); // 接收方的邮箱
email.setFrom(sendemail); // 发送方
email.setSubject(title); // 标题
email.setCharset(encoding);
email.setMsg(p); // p为用户的密码
email.send();
}
}