Spring Boot MailAuthenticationException: Authentication failed / 535 (spring.mail.* properties)
Spring's JavaMailSender can't authenticate to the SMTP server.
org.springframework.mail.MailAuthenticationException: Authentication failedMailAuthenticationException Spring Boot 535jakarta.mail.AuthenticationFailedException: 535 5.7.8 Username and Password not acceptedAuthentication failed; nested exception is jakarta.mail.AuthenticationFailedException Meaning
Check spring.mail.host, port, username, password, and the property block: spring.mail.properties.mail.smtp.auth=true and starttls.enable=true (587) or ssl.enable=true (465). Use an app password for Gmail/Outlook, and make sure the property names are exact (a typo silently disables auth).
Common causes
mail.smtp.authmissing- Wrong username (full address) or password
- STARTTLS/SSL flag missing
- Provider requires app password/OAuth2
- Property typos
⚡ Quick fix
- Set
spring.mail.properties.mail.smtp.auth=trueandstarttls.enable=true - Use an app password
- Enable debug:
spring.mail.properties.mail.debug=true
Detailed fix by platform
Properties
- bash
spring.mail.host=smtp.example.com spring.mail.port=587 spring.mail.username=${SMTP_USER} spring.mail.password=${SMTP_PASS} spring.mail.properties.mail.smtp.auth=true spring.mail.properties.mail.smtp.starttls.enable=true
How to diagnose
- smtp.auth — true?
- STARTTLS — Enabled?
- Password — App-specific?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
- 454 454 4.7.0 Temporary authentication failure (SMTP AUTH backend unavailable)
- 530 5.7.0 Authentication Required SMTP: 530 5.7.0 Must issue a STARTTLS command first / 530 5.7.1 Authentication required
- 534 5.7.9 Application-specific password required SMTP: 534-5.7.9 Application-specific password required. Learn more at https://support.google.com/accounts/answer/185833
Most viewed in Email / SMTP
- 550 5.7.1 550 5.7.1 Relaying denied / Message rejected as spam / Unauthenticated email not accepted
- Laravel: Connection could not be established with host Laravel: Symfony\Component\Mailer\Exception\TransportException: Connection could not be established with host "smtp.mailtrap.io:2525": stream_socket_client(): Unable to connect
- self-signed certificate (SMTP TLS) Nodemailer: Error: self signed certificate in certificate chain (code: 'ESOCKET') / unable to verify the first certificate
Other ways to find it
Where this error sits
Origin: Network. Errors that are often confused with or caused by this one (click to open):
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 18 Nov 2026