Spring Mail Email / SMTP Origin: Network OSI layer 7 · Application Last updated 18 Nov 2026

Spring Boot MailAuthenticationException: Authentication failed / 535 (spring.mail.* properties)

Spring's JavaMailSender can't authenticate to the SMTP server.

Exact message you may see 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
Seen on: Java Spring Boot SMTP

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.auth missing
  • Wrong username (full address) or password
  • STARTTLS/SSL flag missing
  • Provider requires app password/OAuth2
  • Property typos

⚡ Quick fix

  1. Set spring.mail.properties.mail.smtp.auth=true and starttls.enable=true
  2. Use an app password
  3. Enable debug: spring.mail.properties.mail.debug=true

Detailed fix by platform

Properties

  1. 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

  1. smtp.auth — true?
  2. STARTTLS — Enabled?
  3. 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:

Where this error sits

Origin: Network. Errors that are often confused with or caused by this one (click to open):

454 — 454 4.7.0 Temporary authentication failure (SMTP AUTH backend unavailable) (Email / SMTP)454530 5.7.0 Authentication Required — SMTP: 530 5.7.0 Must issue a STARTTLS command first / 530 5.7.1 Authentication required (Email / SMTP)530 5.7.0 Authenticat…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 (Email / SMTP)534 5.7.9 Application…535 5.7.8 Username and Password not accepted — SMTP: 535-5.7.8 Username and Password not accepted. Learn more at https://support.google.com/mail/?p=BadCredentials (Email / SMTP)535 5.7.8 Username an…JavaMail — javax.mail.MessagingException: Could not connect to SMTP host: smtp.example.com, port: 587 (JavaMail) (Email / SMTP)JavaMailNodemailer: EAUTH Invalid login — Nodemailer: Error: Invalid login: 535-5.7.8 Username and Password not accepted (code: 'EAUTH', responseCode: 535) (Email / SMTP)Nodemailer: EAUTH Inv…SmtpClientAuthentication is disabled for the Tenant — SMTP: 535 5.7.139 Authentication unsuccessful, basic authentication is disabled / SmtpClientAuthentication is disabled for the Tenant (Email / SMTP)SmtpClientAuthenticat…Spring Ma…

Explore the map of this error Full error map →

🧠 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.