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

**Code:** `Spring Mail` · **Category:** Email / SMTP · **Seen on:** Java, Spring Boot, SMTP

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

## 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?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/email/spring-mail-authentication-failed-535)
