//创建ession和一个新的邮件消息
//Session mailSession = Session.getInstance(props);
//Message msg = new MimeMessage(mailSession);
//
Authenticator a = new Authenticator(){
public PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication("test", "code");
}
};
Session mailSession = Session.getInstance(props,a);
Message msg = new MimeMessage(mailSession);
//设置the FROM, TO, DATE and SUBJECT fields
msg.setFrom(new InternetAddress(fromEmail));
msg.setRecipients(
Message.RecipientType.TO,
InternetAddress.parse(toEmail));
msg.setSentDate(new Date());
msg.setSubject("Test Mail");