5.7.57 Client was not authenticated to send anonymous mail during MAIL FROM
5.7.57 SMTP; Client was not authenticated to send anonymous mail during MAIL FROMShort 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.
Fix it fast
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 SmtpClientAuthenticationDisabled2Match what you see, then jump to its fix
- 1
Error says anonymous mail; the app has no username or password for the server.The app sends no mailbox credentialsFix - 2
The app sends without sign-in on purpose, to your own domain's recipients.smtp.office365.com is used for direct sendFix - 3
The first-step command prints SmtpClientAuthenticationDisabled : True.SMTP AUTH is disabled for the mailboxFix - 4
SMTP AUTH is enabled on the mailbox and the error continues.Security defaults or a policy blocks basic sign-inFix
- 1
What does the error look like?
5.7.57 SMTP; Client was not authenticated to send anonymous mail during MAIL FROM530 5.7.57 Client not authenticated to send mail535 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.com3Verify
A test message is accepted instead of the anonymous-mail error.
openssl s_client -starttls smtp -connect smtp.office365.com:587 -brief </dev/nullConfirmed by learn.microsoft.com
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.com2Fix
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: 253Verify
A message to a mailbox in your organization arrives.
dig +short MX contoso.comConfirmed by learn.microsoft.com
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 SmtpClientAuthenticationDisabled2Fix
Enable it for the one mailbox that needs it.
Set-CASMailbox -Identity me@contoso.com -SmtpClientAuthenticationDisabled $false3Verify
The check now shows False.
Get-CASMailbox -Identity me@contoso.com | Format-List SmtpClientAuthenticationDisabledConfirmed by learn.microsoft.com
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/nullConfirmed by learn.microsoft.com
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
SmtpException: Unable to read data from the transport connection (net_io_connectionclosed)
System.Net.Mail.SmtpException: Unable to read data from the transport connection: net_io_connectionclosed.
The server closed the connection while SmtpClient was waiting for a reply.
4 causes, each with a fixCodeIgniter email does not send and shows no error message
$email->printDebugger() prints an empty result
CodeIgniter signals a failed email only by send() returning false, with no exception.
4 causes, each with a fixDjango 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 fixDKIM shows 'bad version' or 'unknown key type' because the DNS key record is malformed
dkim=fail (unknown key type)
These results mean the receiver found your DKIM key record but could not use it.
4 causes, each with a fixDovecot refuses to start: Can't load SSL certificate, no valid PEM certificate
doveconf: Error: ssl enabled, but ssl_cert not set
Dovecot reads the ssl_cert setting as the file's contents, not a path, so in 2.3 the value must start with a less-than sign.
3 causes, each with a fixMail 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