javax.mail.AuthenticationFailedException: 535 5.7.3 Authentication unsuccessful

EC Platform 5 Reputation points
2023-05-17T10:40:44.8633333+00:00

use microsoft mail account in java program can not send out email

I have enabled smtp auth

configuration:

spring.mail.default-encoding=utf-8

spring.mail.host=smtp.office365.com

spring.mail.port=587

spring.mail.username=****

spring.mail.password=****

spring.mail.protocol=smtp

spring.mail.properties.mail.smtp.auth=true

spring.mail.properties.mail.transport.protocol=smtp

spring.mail.properties.mail.smtp.starttls.enable=true

spring.mail.properties.mail.smtp.ssl.socketFactory.class=com.sun.mail.util.MailSSLSocketFactory

spring.mail.properties.mail.smtp.ssl.socketFactory.fallback=false

spring.mail.properties.mail.debug=true

code:

@RequestMapping("/simple")

public void SendSimpleMessage(MailRequest mailRequest) {

SimpleMailMessage message = new SimpleMailMessage();

//邮件发件人

message.setFrom(sendMailer);

//邮件收件人 1或多个

message.setTo(mailRequest.getSendTo().split(","));

//邮件主题

message.setSubject(mailRequest.getSubject());

//邮件内容

message.setText(mailRequest.getText());

//邮件发送时间

message.setSentDate(new Date());

javaMailSender.send(message);

}

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
12,049 questions
0 comments No comments
{count} vote

1 answer

Sort by: Most helpful
  1. Shubham Shinde 0 Reputation points
    2023-09-18T12:27:24.3266667+00:00

    i'm also having same problem anyone help

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.