user10767069
user10767069

Reputation:

getting "javax.mail.AuthenticationFailedException: 535-5.7.8 Username and Password not accepted" this error

Getting error on sending mail.Even though the exact properties inside application.properties worked few months back.

This is the properties to configure mail sending inside application.properties

mail.enable=true
spring.mail.host=smtp.gmail.com
[email protected]
spring.mail.password=**************
spring.mail.properties.mail.smtp.auth=true

spring.mail.properties.mail.smtp.socketFactory.port=465

mail.smtp.port=2525

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

spring.mail.properties.mail.smtp.socketFactory.class=javax.net.ssl.SSLSocketFactory
spring.mail.properties.mail.smtp.socketFactory.fallback=false

[email protected]    

How can I reconfigure this? I tried by following specific password pattern. Would appreciate any sort of suggestions.

Upvotes: 1

Views: 8945

Answers (2)

go to https://myaccount.google.com/security

on the section Less secure app access select Turn on access and click on Allow less secure apps: OFF

My application.properties looks like this:

logging.level.org.springframework.mail=DEBUG
spring.mail.host=smtp.gmail.com
spring.mail.port=587
spring.mail.username=enter_here_your_email
spring.mail.password=enter_here_your_password
spring.mail.properties.mail.smtp.auth=true
spring.mail.properties.mail.smtp.connectiontimeout=5000
spring.mail.properties.mail.smtp.timeout=5000
spring.mail.properties.mail.smtp.writetimeout=5000
spring.mail.properties.mail.smtp.starttls.enable=true

Upvotes: -2

Romil Patel
Romil Patel

Reputation: 13727

For Gmail

spring.mail.host=smtp.gmail.com
spring.mail.port=587
[email protected]
spring.mail.password= Your Generated App Password (not your Gmail Account Password)
spring.mail.properties.mail.smtp.auth=true
spring.mail.properties.mail.smtp.starttls.enable=true

How to generate your App Password? Click Here

Upvotes: 8

Related Questions