A "535 5.7.8 Authentication credentials invalid" reply means a mail server refused the username and password an SMTP client offered, and the same line appears whether a scanner has a stale password or an attacker is spraying thousands of mailboxes. Telling the two apart quickly matters, because a single broken device is a help desk ticket while a burst of 535 replies across many accounts is a credential attack against one of the last places Basic authentication still survives. This guide explains what the code means in the standards, triages the benign causes, shows the log fields that reveal spraying, and sets out how to shut the door by disabling Basic SMTP AUTH. It is for email administrators and SOC analysts running Exchange Online, Google Workspace or self-hosted mail servers such as Postfix. It is defensive only: it describes how spraying looks in logs, not how to perform it.
Key takeaways
- 535 5.7.8 is a permanent credential failure. RFC 4954 defines it as authentication failing because of invalid or insufficient credentials, and tells the client to ask the user for new ones rather than retry silently.
- Most single-account failures are benign. Changed passwords, MFA enrolment, disabled Basic authentication and wrong usernames account for the majority of one-off 535 replies from known devices.
- The pattern, not the code, reveals spraying. Many distinct usernames failing from one source, or one password tried across many accounts at a slow rate, is the signature of ATT&CK T1110.003 Password Spraying.
- Disabling Basic SMTP AUTH removes the target. In Exchange Online an authentication policy blocks Basic authentication before the request reaches the identity provider, so sprayed passwords are never even tested.
- The senders that remain are non-human identities. Printers, applications and app passwords that still use SMTP AUTH need an owner, a single mailbox, OAuth or a relay, and monitoring.
What 535 5.7.8 means
An SMTP reply carries two codes. The three digit basic code (535) comes from SMTP itself and the enhanced status code (5.7.8) adds detail in the class.subject.detail format registered by IANA. Class 5 is a permanent failure, so the server is saying that resending the same thing will not work. Subject 7 covers security or policy, and detail 8 is "Authentication credentials invalid", defined in RFC 4954, the SMTP Service Extension for Authentication (Standards Track, July 2007, which obsoletes RFC 2554). The IANA registry lists 535 and 554 as the basic codes that may accompany X.7.8.
The code is only returned in response to the AUTH command. The client offers a SASL mechanism (typically PLAIN or LOGIN for passwords, XOAUTH2 for OAuth tokens), the server sends 334 challenges, and the exchange ends with 235 2.7.0 on success or a failure code. RFC 4954 says that after 535 5.7.8 the client should ask the user for new credentials, for example with a password dialog. Unattended devices cannot do that, which is why a failing scanner may retry in a loop and generate the same volume of failures an attacker would.
Related AUTH reply codes
| Reply | Meaning (RFC 4954 / RFC 5248) | What it usually tells you |
|---|---|---|
| 235 2.7.0 | Authentication succeeded | A successful AUTH; after a run of 535 replies from the same source, treat it as a possible compromise |
| 535 5.7.8 | Authentication credentials invalid | Wrong password or username, or the server's policy refuses the credential type |
| 534 5.7.9 | Authentication mechanism is too weak | Server policy needs a stronger mechanism for that user; the client should retry with one |
| 454 4.7.0 | Temporary authentication failure | Server side fault such as a back-end directory being unreachable; the client should not reprompt for a password |
| 530 5.7.0 | Authentication required | The client tried to send (MAIL FROM) without authenticating first |
| 538 5.7.11 | Encryption required for the mechanism | Kept for historical purposes; modern servers should not advertise plaintext mechanisms before TLS |
| 525 5.7.13 | User account disabled | An administrator disabled the account (RFC 5248) |
| 535 5.7.14 | Trust relationship required | The submission server needs a configured trust with a third party server (RFC 5248, replacing an earlier use of X.7.8) |
Providers add their own text and sometimes their own detail codes after the number. Exchange Online, for instance, returns 535 5.7.3 Authentication unsuccessful when an OAuth SMTP sign-in fails. Read the full reply text, not just the number, and record it in the ticket.
Benign causes
Start every investigation of a single account by assuming a configuration fault, then rule it out. The table covers the causes seen most often in practice.
| Cause | Clue in the logs or reply | Fix |
|---|---|---|
| Password changed or expired, device not updated | One account, one known source IP, failures start on the day of a reset | Move the sender to OAuth or a relay rather than typing the new password into the device |
| Basic authentication disabled for the tenant or mailbox | Started after a policy change or a provider retirement date; Exchange may return its own 5.7.x text | Use OAuth (XOAUTH2) or a relay; see the Exchange Online SMTP AUTH Basic Auth Retirement |
| MFA enforced on the account | Correct password still rejected; sign-in log shows an MFA or Conditional Access interruption | Do not exclude the account from MFA; move the device off password authentication |
| Wrong username format | Device sends a short name or a display name instead of the full address | Use the full user principal name or email address |
| App password revoked or not created | Account has 2-Step Verification and the device uses the normal password | Prefer OAuth or relay; if an app password is unavoidable, issue one per device and record it |
| Provider retired username and password sign-in | Google Workspace: from 1 May 2025 less secure apps and devices that sign in with a username and password are no longer supported | OAuth, the Workspace SMTP relay service (IP authenticated) or smtp.gmail.com with an app password |
| Account locked or disabled | Sign-in log shows a lockout error; or 525 5.7.13 from servers that use RFC 5248 | Find what locked it before unlocking; a lockout can be the first sign of spraying |
| Wrong mechanism or TLS order | Client sends AUTH before STARTTLS and the server does not advertise PLAIN or LOGIN yet | Configure the client for STARTTLS on 587 or implicit TLS on 465 |
A benign cause has a recognisable shape: one account, one source the organisation owns, and a start time that lines up with a change. Anything that breaks that shape moves to the next section.
Spraying and brute force patterns
SMTP AUTH attracts password attacks because it often accepts a plain username and password, is reachable from the internet on ports 587 and 465, and in many tenants sits on accounts excluded from MFA so devices keep working. MITRE ATT&CK describes the relevant behaviours under T1110 Brute Force.
| Pattern | ATT&CK | How it shows up in 535 data |
|---|---|---|
| Password spraying | T1110.003 | Many different usernames, few attempts each, often one password per round, spread over hours from one IP or a rotating pool |
| Password guessing | T1110.001 | One username, many different passwords in a short window, frequently ending in a lockout |
| Credential stuffing | T1110.004 | Username and password pairs from breach lists; low failure rate per account, scattered successes, addresses that include former staff and aliases |
| Use of a valid cloud account | T1078.004 | A 235 2.7.0 or successful sign-in after failures, followed by sending from an unusual location or volume |
| Remote email collection | T1114.002 | After a spray succeeds, the same credential used on IMAP, POP or web mail to read the mailbox |
Three signals separate a spray from a broken device. Breadth: the number of distinct usernames failing from one source per hour. Unknown targets: attempts against addresses that do not exist, former employees or role aliases nobody signs in to. Source: hosting provider or residential proxy ranges instead of your office or a known vendor. Attackers deliberately stay below lockout thresholds, so a quiet, wide pattern is more worrying than a loud, narrow one. See the Password Spraying and Credential Stuffing Defence Guide for the wider defence.
Detection in mail and sign-in logs
Collect three sources: the mail server or provider's SMTP log, the identity provider's sign-in log, and any SMTP client report the provider offers. The fields below are the ones to keep in your SIEM.
| Source | Fields to keep | Use |
|---|---|---|
| Microsoft Entra sign-in logs (interactive and non-interactive) | Client app, Sign-in error code and failure reason, IP address, Location, Conditional Access status, isInteractive | Filter Client app for legacy protocols; "Not Applied" Conditional Access on a legacy sign-in shows a policy gap |
| Exchange Online SMTP AUTH clients report | Sender address, Authentication Protocol (Basic or Modern), TLS version, volume, up to 90 days | Inventory of who still authenticates, and new senders that appear without a ticket |
| Postfix and similar MTAs | SASL failure lines with client hostname and IP, SASL username, mechanism, TLS state | Count distinct usernames per client IP; flag AUTH attempted without TLS |
| Firewall or load balancer | Connections to 587 and 465 by source, geolocation, ASN | Spot new sources hitting submission ports and rate limit them |
| Help desk and lockout records | Lockout events and reset requests by account | Clusters of lockouts across unrelated users point to spraying |
Run detections such as these, tuned to your baseline:
- Breadth rule: more than a set number of distinct usernames with 535 or a failed legacy sign-in from one IP in an hour.
- Success after failures: a successful SMTP AUTH or sign-in for an account within a short window after failures from the same source. Escalate immediately.
- Unknown account targeting: failures for usernames that do not exist in the directory.
- New legacy client: a first-seen account using a legacy Client app value, or a new sender in the SMTP AUTH clients report.
- Policy drift: changes to SmtpClientAuthenticationDisabled, authentication policies or Conditional Access exclusions.
For KQL against Entra logs, see How to detect password spraying in Entra ID sign-in logs with KQL, and for broader field coverage the Entra ID Sign-In and Audit Log Detection Guide.
Mitigation: disable SMTP AUTH, modern auth, lockout
Exchange Online
- Organisation switch: Microsoft recommends turning SMTP AUTH off for the organisation and on only for mailboxes that still need it:
Set-TransportConfig -SmtpClientAuthenticationDisabled $true. A per mailbox value set withSet-CASMailboxoverrides the organisation, and$nullmeans the mailbox follows the organisation. - Authentication policy:
New-AuthenticationPolicycreates a policy with every AllowBasicAuth switch off, including AllowBasicAuthSmtp. Assign it withSet-User -AuthenticationPolicyor make it the default withSet-OrganizationConfig -DefaultAuthenticationPolicy. Microsoft documents that a blocked Basic request is stopped at the first pre-authentication step, before it reaches Entra ID or an on-premises identity provider, so spray attempts do not test passwords or trigger lockouts. Changes take up to 24 hours unless you force a refresh. - Federated caveat: for usernames that do not exist in Exchange Online, requests are still forwarded to on-premises AD FS during a spray, so keep AD FS extranet lockout in place.
- Conditional Access: a policy that blocks the Exchange ActiveSync clients and Other clients conditions stops legacy authentication; create it in report-only mode first and exclude only emergency access accounts. See the Conditional Access Guide.
- Security defaults: when Entra security defaults are on, SMTP AUTH and Basic authentication are already disabled.
- Lockout: Entra smart lockout defaults to 10 failed attempts and a 60 second first lockout in Azure Public tenants, keeps separate counters for familiar and unfamiliar locations, and does not count repeats of the same bad password. It slows guessing but is not a fix for spraying, which stays under the threshold.
Google Workspace
- OAuth or relay: username and password sign-in for less secure apps ended on 1 May 2025. Devices should use OAuth, the SMTP relay service at smtp-relay.gmail.com authenticated by IP address, or smtp.gmail.com with an app password where 2-Step Verification is on.
Self-hosted servers (Postfix example)
- TLS before AUTH: set
smtpd_tls_auth_only = yesso AUTH is offered only inside TLS. - Mechanism policy: include
noanonymousinsmtpd_sasl_security_optionsand keepnoplaintextfor unencrypted sessions; RFC 4954 requires servers to support a configuration with no plaintext mechanisms outside TLS. - Scope AUTH: offer SASL (
smtpd_sasl_auth_enable) only on the submission service, not on port 25 inbound MX. - Rate limit and ban: throttle connections and AUTH attempts per client and block sources that exceed a failure threshold.
Implementation order
- Export 90 days of SMTP AUTH and legacy sign-in data and list every sender that still uses a password.
- Assign each sender an owner and a destination: OAuth SMTP, a relay connector, a high volume or relay service, or an API such as Microsoft Graph.
- Deploy the blocking Conditional Access or authentication policy in report-only mode or to a pilot group, and watch for 535 and failed sign-ins from known senders.
- Disable SMTP AUTH per mailbox as each sender moves, then at organisation level.
- Remove the MFA and Conditional Access exclusions that existed for those mailboxes, and reset their passwords.
- Rollback: re-enable SMTP AUTH on the single affected mailbox with a dated exception and owner, never tenant-wide.
Where identity fits
Every remaining SMTP AUTH sender is a non-human identity: a service mailbox in a printer, an application's password, or an app password. Each needs one purpose, one mailbox, an owner, a credential expiry and a review date. App passwords bypass MFA by design, and Microsoft notes that blocking Basic authentication also blocks app passwords, so plan their replacement. See the App Passwords Security Guide.
Common failure patterns
- Treating 535 as noise: teams suppress the alert because devices fail all day, and miss the day the breadth tripled.
- Tenant-wide re-enable: one broken printer leads to SMTP AUTH being turned back on for the whole organisation, reopening every mailbox.
- MFA exclusions for devices: service mailboxes kept outside MFA and Conditional Access are the easiest accounts to spray and are rarely watched.
- Lockout as the only control: thresholds stop guessing against one account but sprays stay below them, and aggressive lockout turns a spray into a denial of service.
- Only watching interactive sign-ins: legacy protocol attempts often appear in non-interactive logs; filtering one tab hides them.
- Ignoring the success after the failures: a 235 or successful sign-in following a burst of 535 replies is the event that matters and needs a password reset and session revocation straight away. Follow the Password Spraying Attack Response Playbook.
Measurement and framework mapping
- Basic SMTP AUTH senders: count trending to zero.
- Mailboxes with SMTP AUTH enabled: every one matched to a register entry with an owner.
- Distinct usernames failing per source per day: baseline and alert on spikes.
- Time to contain: from first success after failures to password reset and session revocation.
- MFA exclusions for mail senders: trending to zero.
| Framework | Reference | How it applies |
|---|---|---|
| NIST CSF 2.0 | PR.AA-03, DE.CM-03, DE.AE-02 | Senders authenticated with strong methods; usage monitored; failures analysed |
| NIST SP 800-53 Rev. 5 | AC-7, IA-2, IA-5, CM-7, AU-6, SI-4 | Unsuccessful logon handling, authentication, authenticator management, disabling unneeded protocols, log review, monitoring |
| MITRE ATT&CK | T1110.003, T1110.001, T1110.004, T1078.004 | Spraying, guessing, stuffing and valid account use against SMTP AUTH |
Practitioner checklist
- Record the full reply text and source IP for every 535 5.7.8 investigation.
- Run the benign cause triage before escalating a single account failure.
- Alert on distinct usernames failing per source and on success after failures.
- Collect both interactive and non-interactive sign-in logs and the SMTP AUTH clients report.
- Disable SMTP AUTH at organisation level and enable it per mailbox only with an owner.
- Apply an authentication policy or Conditional Access block for Basic and legacy authentication, piloted in report-only mode.
- Move devices and applications to OAuth, relay or an API, and remove their MFA exclusions.
- Require TLS before AUTH and no plaintext mechanisms on self-hosted submission services.
- Register every remaining sending identity and app password with an expiry and review date.
Standards and references
- IETF: RFC 4954 SMTP Service Extension for Authentication
- IANA: Simple Mail Transfer Protocol (SMTP) Enhanced Status Codes Registry
- Microsoft Learn: Enable or disable SMTP AUTH in Exchange Online
- Microsoft Learn: Disable Basic authentication in Exchange Online
- Microsoft Learn: Block legacy authentication with Conditional Access
- Microsoft Learn: Microsoft Entra smart lockout
- Google Workspace: Send email from a printer, scanner or app
- Postfix: SASL Howto
Related NHI Mgmt Group resources: Exchange Online SMTP AUTH Basic Auth Retirement · Password Spraying and Credential Stuffing Defence Guide · Exchange Online Security Guide · App Passwords Security Guide