Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Email delivery

5.7.57 Client was not authenticated to send anonymous mail during MAIL FROM

Error5.7.57 SMTP; Client was not authenticated to send anonymous mail during MAIL FROM

Short answer

Microsoft 365 got a message from a connection that had not signed in. Either your app sends no username and password to smtp.office365.com, or it uses that endpoint for direct send, or SMTP AUTH is disabled or blocked for the mailbox. Check the credentials first, then the mailbox setting.

  • Applies to Exchange Online, smtp.office365.com port 587
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Ask Exchange Online whether SMTP AUTH is switched off for the mailbox your app signs in with.

    Get-CASMailbox -Identity me@contoso.com | Format-List SmtpClientAuthenticationDisabled
  2. 2Match what you see, then jump to its fix

    1. 1Error says anonymous mail; the app has no username or password for the server.The app sends no mailbox credentialsFix
    2. 2The app sends without sign-in on purpose, to your own domain's recipients.smtp.office365.com is used for direct sendFix
    3. 3The first-step command prints SmtpClientAuthenticationDisabled : True.SMTP AUTH is disabled for the mailboxFix
    4. 4SMTP AUTH is enabled on the mailbox and the error continues.Security defaults or a policy blocks basic sign-inFix

What does the error look like?

  • 5.7.57 SMTP; Client was not authenticated to send anonymous mail during MAIL FROM
  • 530 5.7.57 Client not authenticated to send mail
  • 535 5.7.3 Authentication unsuccessful

Cause 1 of 4

The app sends no mailbox credentials

1Check

smtp.office365.com is the client submission endpoint, so the app must sign in to a mailbox. The error appears when no logon credentials were entered, or when a device has no field for them.

grep -rn -i -E "smtp.office365.com|Credentials|password" src/ config/

2Fix

Enter the mailbox address and password (or use OAuth), use port 587 with TLS on, and send from the same address you sign in with. If the app cannot sign in at all, use direct send or SMTP relay instead.

host: smtp.office365.com
port: 587
starttls: true
username: me@contoso.com

3Verify

A test message is accepted instead of the anonymous-mail error.

openssl s_client -starttls smtp -connect smtp.office365.com:587 -brief </dev/null

Confirmed by learn.microsoft.com

Did this fix it?

Cause 2 of 4

smtp.office365.com is used for direct send

1Check

Direct send must not use the client submission endpoint. It uses your domain's MX endpoint, which ends in mail.protection.outlook.com, on port 25.

dig +short MX contoso.com

2Fix

Point the app at the MX endpoint (for example contoso-com.mail.protection.outlook.com) on port 25. Direct send reaches recipients in your own organization only.

host: contoso-com.mail.protection.outlook.com
port: 25

3Verify

A message to a mailbox in your organization arrives.

dig +short MX contoso.com

Confirmed by learn.microsoft.com

Did this fix it?

Cause 3 of 4

SMTP AUTH is disabled for the mailbox

1Check

SMTP AUTH is off by default for organizations created after January 2020, and a per-mailbox setting overrides the organization setting.

Get-CASMailbox -Identity me@contoso.com | Format-List SmtpClientAuthenticationDisabled

2Fix

Enable it for the one mailbox that needs it.

Set-CASMailbox -Identity me@contoso.com -SmtpClientAuthenticationDisabled $false

3Verify

The check now shows False.

Get-CASMailbox -Identity me@contoso.com | Format-List SmtpClientAuthenticationDisabled

Confirmed by learn.microsoft.com

Did this fix it?

Cause 4 of 4

Security defaults or a policy blocks basic sign-in

1Check

With security defaults on, SMTP AUTH is already disabled. A Conditional Access policy that blocks legacy authentication, or an authentication policy that disables basic auth for SMTP, has the same effect.

echo 'Entra admin center > Overview > Properties > Manage security defaults; Security > Conditional Access'

2Fix

Prefer moving the app to OAuth, which Microsoft recommends, or exclude the one mailbox from the policy that blocks legacy sign-in.

echo 'Exclude the mailbox under Users > Exclude in the legacy-authentication policy'

3Verify

The app signs in and sends.

openssl s_client -starttls smtp -connect smtp.office365.com:587 -brief </dev/null

Confirmed by learn.microsoft.com

Did this fix it?

How do I stop it coming back?

  • Give each app its own mailbox with SMTP AUTH enabled for that mailbox only.
  • Plan the move to OAuth: Microsoft has scheduled basic authentication for client submission for deprecation.
  • Send from the address you sign in with, or grant Send As permission.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Related fixes

Email

Django send_mail fails or hangs with an SSL error

smtplib.SMTPException raised from send_mail()

Django has two secure modes that must not be mixed: EMAIL_USE_TLS for explicit TLS (STARTTLS, usually port 587) and EMAIL_USE_SSL for implicit TLS (usually port 465).

4 causes, each with a fix

Email

Mail from your own domain keeps landing in the spam folder

dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=example.com

Open a message that went to spam and read its Authentication-Results header: it shows whether SPF, DKIM and DMARC passed, and for which domain.

5 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.