如何通过在网站注册时发送激活邮件给用户邮箱啊
public final class EmailUtil {
public static void sendEmail(String emailAddr, String verifyCode) {
System.out.println("给" + emailAddr + "发送验证码" + verifyCode);
// 邮件发送
SimpleEmail email = new SimpleEmail();
email.setHostName("smtp.sina.cn");
email.setAuthentication("wanzheng2326", "11111111");
email.setCharset("UTF-8");
try {
email.addTo(emailAddr);
email.setFrom("wanzheng2326@sina.cn");// 必须和Authentication使用的用户相同,否则失败
email.setSubject("邮箱验证码");
email.setMsg("恭喜您注册成功,邮箱验证码为" + verifyCode);
email.send();
} catch (EmailException e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
EmailUtil.sendEmail("58742094@qq.com", "66");
}
}
我这个有异常啊
Sending the email to the following server failed : smtp.sina.cn:25
请高手指教!!
[解决办法]
新浪免费邮箱发信(smtp)服务器的地址为:smtp.sina.com