Exchange Connection Problems

Send a CSV Report Through Office 365 SMTP Using PowerShell

Ayan MasoodAyan Masood Nov 13, 2026 870 views

Question details

The user needs to send a CSV report through Office 365 SMTP using PowerShell but encounters the 5.7.57 SMTP Client was not authenticated error and asks how to configure TLS, authentication, and SMTP AUTH correctly.

Send a CSV Report Through Office 365 SMTP Using PowerShell
Product
Microsoft Office 365 / Exchange Online
Device & OS
not provided
Scenario
Automating a CSV report submission from PowerShell to Office 365 SMTP on port 587.
Observed behavior
The SMTP connection is rejected by smtp.office365.com with error 5.7.57 SMTP; Client was not authenticated because TLS, authentication, or SMTP AUTH is missing or misconfigured.
Before you start

Before changing the script, confirm the sending mailbox has SMTP AUTH enabled in Microsoft 365 admin center and note the exact hostname, port, and sender address. Avoid testing with a personal Microsoft account because Office 365 SMTP client submission requires a licensed Exchange Online mailbox.

Solution 1Recommended

Configure PowerShell to send a CSV report through smtp.office365.com with TLS and authentication

Use this solution to fix the 5.7.57 error by setting the correct Office 365 SMTP host, port, TLS option, and credentials in the PowerShell script.

Office 365 SMTP client submission requires smtp.office365.com on port 587 with TLS/SSL enabled and a licensed Exchange Online mailbox credential. The steps below use Send-MailMessage, but note that Microsoft considers this cmdlet obsolete; use it only while you plan a migration to Microsoft Graph or an approved relay.

1
Define the Office 365 SMTP server and port

In the PowerShell script, set -SmtpServer smtp.office365.com, -Port 587, and -UseSsl to enable TLS before sending the CSV report.

2
Attach the CSV report and supply credentials

Call Send-MailMessage with -From the sending mailbox, -To the recipient, -Subject, -Body, -Attachments "C:\Reports\report.csv", and -Credential $credential so Office 365 authenticates the mailbox.

3
Create a secure credential object

Run $credential = Get-Credential or use a secure string from Export-Clixml so the mailbox password is not stored in plain text in the script.

Configure PowerShell to send a CSV report through smtp.office365.com with TLS and authentication
Use a dedicated Exchange Online mailbox: Authenticated SMTP client submission only works for licensed Exchange Online mailboxes with SMTP AUTH enabled; it does not work reliably with personal Microsoft accounts.
Free Microsoft Office alternative

Use WPS Office to Prepare CSV Reports While Keeping Office 365 SMTP Delivery

WPS Office does not change how Office 365 SMTP authentication works, but it is a free, lightweight Microsoft Office alternative. You can open, edit, and save CSV and XLSX reports with full Microsoft Office format compatibility, then send them through your existing Office 365 SMTP or Microsoft Graph script.

Opens and edits CSV and XLSX reports with Microsoft Office format compatibilityFree, lightweight Office alternative for preparing reports without heavy licensingFamiliar ribbon interface and tabbed editing make migration from Microsoft Office easyWorks alongside your existing Office 365 SMTP or PowerShell delivery workflow
microsoft office alternative - wps office

Frequently Asked Questions

Why does Office 365 SMTP return 5.7.57 Client was not authenticated even with the correct password?

Usually because the script is not using TLS/STARTTLS on port 587, SMTP AUTH is disabled for the mailbox or tenant, or the authentication method is blocked by Security defaults. Check smtp.office365.com, port 587, UseSsl, and enable Authenticated SMTP in Microsoft 365 admin center.

What SMTP server and port should I use to send a CSV report through Office 365?

Use smtp.office365.com on port 587 with TLS enabled for SMTP client submission. Port 25 is not intended for authenticated client submission and is commonly blocked.

Is Send-MailMessage still supported in PowerShell?

No, Send-MailMessage is obsolete. It still works in many environments when SMTP AUTH and TLS are configured, but for production automation you should migrate to Microsoft Graph or an approved SMTP relay.

How do I enable SMTP AUTH for a mailbox in Microsoft 365?

In Microsoft 365 admin center, select the user, open Mail > Manage email apps, and enable Authenticated SMTP. Then verify tenant-level SMTP AUTH under Org settings or Exchange admin center.

Can I send CSV email from PowerShell without storing a plain-text password?

Yes. Use Get-Credential or export and import a secure string, or use certificate-based authentication with Microsoft Graph for unattended scripts.