Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

使用outlook账号密码发送邮件失败 #3561

Closed
luzle opened this issue Apr 25, 2024 · 3 comments
Closed

使用outlook账号密码发送邮件失败 #3561

luzle opened this issue Apr 25, 2024 · 3 comments
Labels

Comments

@luzle
Copy link

luzle commented Apr 25, 2024

版本情况

JDK版本: jdk1.8.0_281
hutool版本: 5.8.27

问题描述(包括截图)

  1. 复现代码
String host="smtp.office365.com";
int port= 587;
// 我登陆https://outlook.live.com/使用的账号
String username = "xxx@qq.com";
String password = "*****";
// 收件人邮箱
String toEmail = "abc@test.com";
MailAccount account = new MailAccount();
account.setHost(host);
account.setPort(port);
account.setAuth(true);
account.setFrom("小红<xxx@qq.com>");
account.setUser(username);
account.setPass(password);
account.setSocketFactoryPort(port);
account.setStarttlsEnable(true);
account.setSslEnable(false);
account.setTimeout(25000);
account.setConnectionTimeout(25000);
try {
    MailSSLSocketFactory sf = new MailSSLSocketFactory();
    sf.setTrustAllHosts(true);
    account.setCustomProperty("mail.smtp.ssl.socketFactory", sf);
} catch (GeneralSecurityException e) {
    throw new RuntimeException(e);
}
MailUtil.send(account,toEmail, "测试邮件", "这是一封测试邮件。", false);

2. 堆栈信息
AuthenticationFailedException: 535 5.7.3 Authentication unsuccessful [SI2P153CA0017.APCP153.PROD.OUTLOOK.COM 2024-04-25T15:34:18.198Z 08DC64C0B4284A22]

Exception in thread "main" java.lang.RuntimeException: cn.hutool.extra.mail.MailException: AuthenticationFailedException: 535 5.7.3 Authentication unsuccessful [SI2P153CA0017.APCP153.PROD.OUTLOOK.COM 2024-04-25T15:34:18.198Z 08DC64C0B4284A22]

	at com.bangdao.ubp.bill.web.controller.HealthChecker.main(HealthChecker.java:290)
Caused by: cn.hutool.extra.mail.MailException: AuthenticationFailedException: 535 5.7.3 Authentication unsuccessful [SI2P153CA0017.APCP153.PROD.OUTLOOK.COM 2024-04-25T15:34:18.198Z 08DC64C0B4284A22]

	at cn.hutool.extra.mail.Mail.send(Mail.java:398)
	at cn.hutool.extra.mail.MailUtil.send(MailUtil.java:416)
	at cn.hutool.extra.mail.MailUtil.send(MailUtil.java:194)
	at cn.hutool.extra.mail.MailUtil.send(MailUtil.java:176)
	at cn.hutool.extra.mail.MailUtil.send(MailUtil.java:161)
	at com.bangdao.ubp.bill.web.controller.HealthChecker.main(HealthChecker.java:286)
Caused by: javax.mail.AuthenticationFailedException: 535 5.7.3 Authentication unsuccessful [SI2P153CA0017.APCP153.PROD.OUTLOOK.COM 2024-04-25T15:34:18.198Z 08DC64C0B4284A22]

	at com.sun.mail.smtp.SMTPTransport$Authenticator.authenticate(SMTPTransport.java:947)
	at com.sun.mail.smtp.SMTPTransport.authenticate(SMTPTransport.java:858)
	at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:762)
	at javax.mail.Service.connect(Service.java:364)
	at javax.mail.Service.connect(Service.java:222)
	at javax.mail.Service.connect(Service.java:171)
	at javax.mail.Transport.send0(Transport.java:230)
	at javax.mail.Transport.send(Transport.java:100)
	at cn.hutool.extra.mail.Mail.doSend(Mail.java:412)
	at cn.hutool.extra.mail.Mail.send(Mail.java:390)
	... 5 more

我想问的是现在使用hutool使用outlook账号密码发送邮件,这个host到底是填什么?我查阅到的信息是
9E69072D-096D-4d68-BBE1-444E0D06FEEE

@luzle
Copy link
Author

luzle commented Apr 25, 2024

期待你可以给一个明确的答复。谢谢

@looly
Copy link
Member

looly commented Apr 27, 2024

嗯……我想你需要检查以下内容:

  1. 你的outlook邮箱账号不应该是xxx@outlook.com么?为何是QQ邮箱?
  2. SSL不应该打开状态?

@luzle
Copy link
Author

luzle commented Apr 27, 2024 via email

@looly looly closed this as completed Apr 27, 2024
@looly looly added the question label Apr 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants