hiFI
hiFI

Reputation: 1961

Sending Email from Office 365 no longer supports Basic Authentication and SMTP

We observe that quite recently our Email were failing to authenticate. Upon finding the reason for such action, we found out that a Policy at Office 365 Admin is causing this issue.

Further, we also found out that it's being blocked by a policy that says our App uses a Legacy Authentication scheme. Later it was understood that Microsoft will stop allowing Basic Authentication (Passing a Username and Password as for credentials) in the future and any connection which uses IMAPI, POP and SMTP protocols for connection. Further communication on Office 365 platform should be on minimum TLS 1.1 or 1.2

I am using a Web Job in Azure to execute Emails and for such System.Net.Mail.SmtpClient for Emailing. This Web Job executes bulk emails. I have checked my App Service, under SSL/TLS properties and have set HTTPS only and TLS 1.2. However, I am using Basic Authentication as the authenticating method. Below is the way I did the coding:

System.Net.Mail.SmtpClient objSmtpClient = null;

//uses the TLS port 587 with authentication
ServicePointManager.ServerCertificateValidationCallback = delegate (object s, System.Security.Cryptography.X509Certificates.X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { return true; };
objSmtpClient = new System.Net.Mail.SmtpClient("email.host.com", 587);
objSmtpClient.UseDefaultCredentials = false;
objSmtpClient.Credentials = new NetworkCredential(userName, passWord);
objSmtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
objSmtpClient.EnableSsl = true;

According to these facts, I want to know what are the other ways I can authenticate to Office 365 Email service on a .NET Framework and send Emails? If,

  1. SMTP protocol is not supported
  2. Basic Authentication is not supported

References: Can I send SMTP email through Office365 shared mailbox?

Upvotes: 2

Views: 4813

Answers (1)

OzBob
OzBob

Reputation: 4510

Microsoft Exchange online Docs say:

disabling SMTP AUTH in all tenants in which it's not being used and SMTP AUTH will still be available when Basic authentication is permanently disabled on October 1, 2022 and The reason SMTP will still be available is that many multi-function devices such as printers and scanners can't be updated to use modern authentication. However, we strongly encourage customers to move away from using Basic authentication with SMTP AUTH when possible.

There are 2 MailKit issues that discuss and show code for options, do any of these work for you when you disable SMTP auth on your m365 test environment tenant?

client.Authenticate (new SaslMechanismPlain ("username", "password"));

1: How can I implement service-to-service authentication with Office365 using the OAuth2 SASL mechanism? 2: Office365 IMAP/POP basic auth retirement October 2020

Does this test pass for you: 'TestSaslInitialResponse'

Upvotes: 2

Related Questions