这是我用来创建会话以发送电子邮件的代码:
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.starttls.enable","true");
props.put("mail.smtp.EnableSSL.enable","true");
logger.trace("1. emailFromAddress: " + emailFromAddress);
session = Session.getDefaultInstance(props,new javax.mail.Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
logger.trace("2. emailFromAddress + " pass: " + password);
return new PasswordAuthentication(emailFromAddress, password);
}
});
然后我尝试输入 emailFromAddress = "abc@yahoo.com" 及其密码。我可以验证地址并成功发送电子邮件,并且
1. emailFromAddress: abc@yahoo.com
2. emailFromAddress: abc@yahoo.com pass: *****
我尝试从不同的 emailFromAddress = "xyz@gmail.com" 发送 --> 这次发送失败并且日志打印输出为:
1. emailFromAddress: xyz@gmail.com --> WHICH IS CORRECT
2. emailFromAddress: abc@yahoo.com pass: ***** --> WHICH STILL REFER TO THE OLD ACCOUNT
会话验证器是否有缓存?