How to Test SMTP Client Submission with PowerShell Send-MailMessage
Question details
The user wants to perform an SMTP client submission test using the PowerShell Send-MailMessage cmdlet to verify email configuration.

- Product
- PowerShell / Exchange
- Device & OS
- not provided
- Scenario
- Verifying correct SMTP server connectivity, port availability, and credential authentication via command-line scripting.
- Observed behavior
- Proper authentication, port, and TLS configurations must be set correctly for the mail service to process the message successfully, keeping in mind that the cmdlet is now considered legacy.
Ensure you have the exact SMTP server address (e.g., smtp.office365.com), port number (usually 587), and valid login credentials before running the script. Additionally, check your mail tenant settings to ensure basic SMTP authentication is enabled for your account.
Test SMTP Submission Using Send-MailMessage
Use the built-in PowerShell cmdlet to quickly test local SMTP configurations with explicit TLS and port settings.
Although marked as obsolete in newer PowerShell guidance, Send-MailMessage remains a quick and viable way to test basic SMTP connectivity and credential validity on local servers or older environments.
Click the Start menu, type 'PowerShell', right-click the Windows PowerShell application, and select 'Run as administrator'.
Type the command `$cred = Get-Credential` and press Enter. A dialog box will appear prompting you to enter the email address and password of the sending account.
Run the following command, replacing the placeholder values with your details: `Send-MailMessage -From "sender@domain.com" -To "recipient@domain.com" -Subject "SMTP Test" -Body "This is a test email." -SmtpServer "smtp.office365.com" -Credential $cred -UseSsl -Port 587`.

Use Microsoft Graph API for Secure Sending
Adopt the modern, supported method for authenticated email submission using Microsoft Graph API, avoiding legacy SMTP Auth vulnerabilities.
Looking for a Reliable, Free Office Suite? Try WPS Office
While IT administrators manage complex PowerShell scripts and SMTP settings for email infrastructure, everyday users just need a seamless way to create, edit, and share documents. WPS Office is a fully compatible, lightweight alternative to Microsoft Office that makes document management effortless and free.
- 1. Download the Installer: Visit the official WPS Office website and click the free download button for your operating system.
- 2. Install the Software: Run the downloaded installer and follow the simple on-screen instructions to complete the setup.
- 3. Create and Share: Open WPS Office to instantly draft documents, spreadsheets, or presentations, and use the built-in share features to email files effortlessly.

Frequently Asked Questions
Why does PowerShell say Send-MailMessage is obsolete?
Microsoft has marked the Send-MailMessage cmdlet as obsolete because it cannot guarantee secure connections natively and does not support modern authentication protocols (OAuth). Microsoft recommends using Microsoft Graph API or third-party modules like MailKit for production environments.
How do I fix authentication errors when running my SMTP test script?
Authentication errors typically occur if 'Security Defaults' are enabled in your Microsoft 365 tenant, which blocks legacy basic authentication. You must either disable security defaults, explicitly enable Authenticated SMTP for the specific user mailbox in the Microsoft 365 Admin Center, or switch to using app passwords if MFA is enforced.
What port should I use for SMTP client submission?
Port 587 is the industry standard for encrypted SMTP client submission. When using port 587 in your script, always ensure that you include the `-UseSsl` parameter to enforce the required TLS encryption.




