1

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
spring.mail.username=abc@gmail.com
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

support.email=abc@gmail.com    

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

user207421
  • 305,947
  • 44
  • 307
  • 483
  • https://stackoverflow.com/questions/35347269/javax-mail-authenticationfailedexception-535-5-7-8-username-and-password-not-ac – Sudhir Ojha Mar 03 '19 at 09:02
  • gone through this and tried also. It didn't work. –  Mar 03 '19 at 09:09
  • Get rid of all the [socket factory settings](https://javaee.github.io/javamail/FAQ#commonmistakes), then post the [JavaMail debug output](https://javaee.github.io/javamail/FAQ#debug). – Bill Shannon Mar 04 '19 at 07:25

2 Answers2

8

For Gmail

spring.mail.host=smtp.gmail.com
spring.mail.port=587
spring.mail.username=example@gmail.com
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

Romil Patel
  • 12,879
  • 7
  • 47
  • 76
-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
Andrew Regan
  • 5,087
  • 6
  • 37
  • 73