我正在尝试通过以下Java代码发送邮件。
today = new Date();
year = this.today.getFullYear();
month = this.today.getMonth();
day = this.today.getDate();
//To go 18 years back
yearsBack18= new Date(this.year - 18, this.month, this.day);
//To go to same day next year
nextYear= new Date(this.year + 1, this.month, this.day);
但是无法发送邮件, 我得到的唯一输出如下:
Properties props = new Properties();
props.put("mail.host",mailProperties.get("mail.smtp"));
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.port", "465");
final PasswordAuthentication pauth;
pauth = new PasswordAuthentication(""+mailProperties.get("mail.user"),""+mailProperties.get("mail.pwd"));
class MyAuthenticator extends Authenticator
{
public PasswordAuthentication getPasswordAuthentication()
{
return pauth;
}
}
Authenticator auth = new MyAuthenticator();
Session mail = Session.getInstance(props,auth);
mail.setDebug(true);
Message msg = new MimeMessage(mail);
Transport.send(msg);
当尝试使用telnet进行检查时,我得到的响应如屏幕截图所示。
请提出我需要进行的任何纠正。