Send a CSV Report Through Office 365 SMTP Using PowerShell
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.

- 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 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.
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.
In the PowerShell script, set -SmtpServer smtp.office365.com, -Port 587, and -UseSsl to enable TLS before sending the CSV report.
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.
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.

Enable SMTP AUTH for the sending mailbox and tenant
Use this when the script uses the correct server and port but Office 365 still rejects the connection because authenticated SMTP is blocked.
Migrate the CSV report script to Microsoft Graph or an approved SMTP relay
Use this for production automation because Send-MailMessage is obsolete and basic SMTP AUTH is being replaced by modern authentication.
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.

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.




