Office365 SMTP AUTH XOAUTH2 Fails with “535 5.7.3 Authentication unsuccessful”

If you successfully minted an OAuth2 access token for your Azure Entra Id App, but then it fails when attempting to use it in the SMTP protocol for sending email with the error: AUTH XOAUTH2 user=xxx auth=Bearer ********************** 535 5.7.3 Authentication unsuccessful [BN9PXXXA0336.namprd03.prod.outlook.com 2024-04-16T12:11:26.548Z 08DC9999186DF999] Check your Entra Id App Registration to make sure you have the following App Permissions:

Solved: Mail Server Error “message body contains illegal bare CR LF characters”

A Chilkat user reported suddenly getting an error message from two receiving mail servers when sending mail generated by Chilkat. The message is:   message body contains illegal bare CR LF characters  Solution:  The cause has been found. The affected users are using AVG or Avast Antivirus and there is an optional signature text added after the outgoing email scan. If […]

SMTP Timeout Sending Large Email

Question: While trying to send an email with an attachment of size 9MB from my application, I get an error.  Interestingly, the file gets delivered to the email address still we get the error in the application. Answer: Looking at the MailMan.LastErrorText for the call to SendEmail, we can see this: ChilkatLog: SendEmail: … ReadTimeout: 30000 … … sendCmdToSmtp: SmtpCmdSent: […]

Office365 SMTP: 535 5.7.139 Authentication unsuccessful, SmtpClientAuthentication is disabled for the Tenant.

This blog post is about the following error encountered when trying to send email via Chilkat.MailMan.SendEmail (using the SMTP protocol). smtpAuthenticate: smtp_host: smtp.office365.com smtp_port: 587 smtp_user: **** smtpAuthenticate: login_method: XOAUTH2 auth_xoauth2: username: **** sendCmdToSmtp: SmtpCmdSent: {PasswordOrCredentials} –sendCmdToSmtp readSmtpResponse: SmtpCmdResp: 535 5.7.139 Authentication unsuccessful, SmtpClientAuthentication is disabled for the Tenant. Visit https://aka.ms/smtp_auth_disabled for more information. [****.PROD.OUTLOOK.COM 2023-07-03T11:15:43.462Z ****] –readSmtpResponse –auth_xoauth2 Failed […]

Office365 Modern Authentication for IMAP, POP3, and SMTP

This post documents how to implement Modern Authentication (OAuth2) for Office365 for the IMAP, POP3, and SMTP protocols.  The very first thing you’ll need to do is to create an “App Registration” in Azure Active Directory. See this Chilkat blog post for Instructions for Setting Up an App Registration in Azure for Modern Authentication for IMAP, SMTP, and POP3. It’s […]

Create Azure App Registration for use with IMAP, POP3, and SMTP

1) Go to https://portal.azure.com/#home and login to your Microsoft account. then go to Azure Active Directory.   2) Click On App Registrations * Copy your Tenant ID, you’ll need it later. 3) Click on “+ New registration” 4) Name your App and Click Register. Give it a name. For the Redirect URI, select “Web” and then use “http://localhost:3017/”. Your application […]

smtp.office365.com – Failed to get initial SMTP Response

If something on the client-side is blocking communications, such as a hardware or software firewall, or anti-virus, then it may be that a TLS connection is established, but then trying to read the 1st message from the server gets blocked.  When this happens, the contents of the LastErrorText look like this.   (The LastErrorText for a successful connection is shown below.) […]

GMail SMTP with Send-Only Scope? (https://www.googleapis.com/auth/gmail.send)

Apparently the full permission scope is required to do XOAUTH2 authentication in the SMTP protocol for GMail. See these examples https://www.example-code.com/vbnet/gmail_smtp_oauth2_access_token.asp https://www.example-code.com/vbnet/gmail_smtp_send_using_oauth2_token.asp The full permission scope is “https://mail.google.com/” The send-only scope is: “https://www.googleapis.com/auth/gmail.send” Google claims that it’s possible to send email with the send-only scope, but we’ve found it is  simply possible.  It just doesn’t work. Don’t know why. Perhaps […]

Office365 SMTP Error: 554 5.2.0 STOREDRV.Submission.Exception:SendAsDeniedException.MapiExceptionSendAsDenied;

Question: I’m trying to send email using SMTP via smtp.office365.com, and I get this error: 554 5.2.0 STOREDRV.Submission.Exception:SendAsDeniedException.MapiExceptionSendAsDenied; Failed to process message due to a permanent exception with message Cannot submit message. 0.35250:0A001485, 1.36674:0A000000, 1.61250:00000000, 1.45378:02000000, 1.44866:59020000, 1.36674:0E000000, 1.61250:00000000, 1.45378:5E020000, 1.44866:F8000000, 16.55847:BC030000, 17.43559:0000000024020000000000000000000000000000, 20.52176:140FFA8B1500001000000000, 20.50032:140FFA8B8517001000000000, 0.35180:F1030000, 255.23226:09000000, 255.27962:0A000000, 255.27962:0E000000, 255.31418:F1030000, 0.35250:0300C981, 1.36674:0A000000, 1.61250:00000000, 1.45378:02000000, 1.44866:3A000000, 1.36674:32000000, 1.61250:00000000, 1.45378:3F000000, 1.44866:01000000, 16.55847:A6000000, […]