Office365 App Setup for SMTP, POP, IMAP OAuth2 Client Credentials

This blog post walks you through the complete Azure App Registration process, including the subsequent Exchange Online PowerShell commands needed to achieve the OAuth2 client credentials flow for Office365 email sending and reading via the SMTP, IMAP, and POP3 protocols. I wish there was an “easy button”, but unfortunately it does not exist. Step 1. Register an Azure App Go […]

ASP VBscript and Office365 OAuth2 Access Token

The Chilkat.OAuth2 class is designed for desktop applications, not server-side web applications. To explain further: The call to OAuth2.StartAuth does 2 things: Returns a URL you’ll open in a browser to interactively get authorization from the service’s account owner. Starts a background thread to act as a web server for the redirect request that will be forwarded from the local […]

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 POP3 Authenticate Fails but Previously Succeeded

It’s normal for OAuth2 access tokens to expire after some time, such as 1 hour, and then you’ll need to refresh and retry. For example, this error in the LastErrorText for a call to Pop3Authenticate could indicate the OAuth2 accces token expired: Pop3Authenticate: DllDate: Mar 28 2023 ChilkatVersion: 9.5.0.94 UnlockPrefix: *** Architecture: Little Endian; 32-bit Language: ActiveX VerboseLogging: 1 Pop3Authenticate: […]

office365.com SMTP, POP3, IMAP OAuth2 Tips, Hints, and Solutions

This page will be updated as time progresses with what we’ve learned about getting things working with OAuth2 authentication for office365.com using the email protocols: SMTP, POP3, and IMAP. How do Other Office365 Users Send Email using my App Registered in my Azure Active Directory? It’s important to understand Tenancy in Azure Active Directory Apps.   See this https://learn.microsoft.com/en-us/azure/active-directory/develop/single-and-multi-tenant-apps When you […]

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.) […]

SMTP / Office 365 / OAuth2 : SmtpCmdResp: 535 5.7.3 Authentication unsuccessful

Question: A customer wants to send emails with Office 365 and OAuth2 Authentication. The setup of the application in Azure is OK. It works for one user. For another user we have the following error: SmtpCmdResp: 535 5.7.3 Authentication unsuccessful [****.****.prod.outlook.com] For authentication I use the example: https://www.example-code.com/powerbuilder/office365_oauth2_access_token.asp What is surprising is that for the second user on same PC, […]

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, […]

Authentication Problem with Sending Email in Office365 using SMTP

If SMTP authentication (using login/password) fails for your smtp.office365.com account, then it may be that your account is configured to require MFA (multi-factor authentication).   You may need to change settings to allow for legacy authentication (single-factor auth).   See https://docs.microsoft.com/en-us/azure/active-directory/conditional-access/block-legacy-authentication Also, an app password may be required.  See https://docs.microsoft.com/en-us/azure/active-directory/user-help/multi-factor-authentication-end-user-app-passwords