0
ofice365アカウントからメールを送信中にJavaエラーが発生しました。ofice365アカウントからメールを送信中にJavaでエラーが発生しました
javax.mail.AuthenticationFailedException:535 5.7.3認証の失敗[MA1PR01CA0090.INDPRD01.PROD.OUTLOOK.COM]
はここに私のコードです。電子メールとパスワードは正しいです。私を助けてください。
final String username = StaticParameters.adminEmail;
final String password = StaticParameters.adminPassword;
Properties props = new Properties();
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.starttls.enable", "true");
props.put("mail.smtp.host", "smtp.office365.com");
props.put("mail.smtp.port", "587");
Session session = Session.getInstance(props,
new javax.mail.Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(username, password);
}
});
try {
Message message = new MimeMessage(session);
message.setFrom(new InternetAddress(username));
message.setRecipients(Message.RecipientType.TO,
InternetAddress.parse(to));
message.setSubject(subject);
message.setContent(body, "text/html; charset=utf-8");
Transport.send(message);
System.out.println("Done");
return true;
} catch (MessagingException e) {
throw new RuntimeException(e);
}
uは、いくつかの電子メールクライアントを経由して、同じ情報を使用してサーバを接続することができますか? – Optional
私はどの電子メールクライアントをテストに使用できますか? –
いずれか1つ、たとえばサンダーバードの見通し – Optional