Sending SMTP email to smtp.office365.com fails

Geezer32 51 Reputation points
2024-12-31T00:02:12.5033333+00:00

I'm trying to use Send-Mailmessage PS to send SMTP using -Get-Credentials to smtp.office365.com but it always ends with the error

Send-MailMessage : The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.57 Client not authenticated to send mail. Error: 535 5.7.139 Authentication unsuccessful, basic authentication is disabled.

The mailbox has a e3 license, MFA is disabled and SMTP auth is enabled for this mailbox but I always get the basic auth denied error. Is using PS to send mail this way considered basic auth?

I need this for new MFD printers with a scan to email function. is there anyway possible to have printers or other devices send SMTP mail to smtp.office365.com anymore?. Note, I am not able to add Exchange connectors to use direct-send in this case.

Azure Communication Services
Azure Communication Services
An Azure communication platform for deploying applications across devices and platforms.
947 questions
Microsoft Exchange Online Management
Microsoft Exchange Online Management
Microsoft Exchange Online: A Microsoft email and calendaring hosted service.Management: The act or process of organizing, handling, directing or controlling something.
4,666 questions
{count} votes

Accepted answer
  1. Xintao Qiao-MSFT 5,320 Reputation points Microsoft Vendor
    2024-12-31T03:10:44.65+00:00

    Hi, @Geezer32

    Yes, the Send-MailMessage cmdlet relies on the SMTP AUTH protocol to send email using Basic Authentication, and Microsoft is phasing out Basic Authentication and starting Modern Authentication.

    In fact, the Send-MailMessage cmdlet is obsolete. This cmdlet doesn't guarantee secure connections to SMTP servers. While there is no immediate replacement available in PowerShell, we recommend you do not use Send-MailMessage.

    If you need to send mail from a device such as an MFD printer, you can configure them to use SMTP relay. This approach allows the device to send mail through Office 365. However, this requires an SMTP relay connector to be set up in Exchange Online. More information can be found How to set up a multifunction device or application to send emails using Microsoft 365 or Office 365 | Microsoft Learn

    For more information about the error message, see Error Message. Fix issues with printers, scanners, and LOB apps that send email using Microsoft 365 - Exchange | Microsoft Learn

    As an alternative, you can use other methods or tools that support modern authentication. For example, you can use the Microsoft Graph API that supports OAuth2 to send mail.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".


1 additional answer

Sort by: Most helpful
  1. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.