Frequently Asked Question
MS365 smtp email testing to 365 2 ways
Last Updated a year ago
One is with authenticated send the other with direct send.
These are powershell scripts, copy them into powershell, edit them as needed then run them.
The authenticated way:
# Get the credential
$credential = Get-Credential
## Define the Send-MailMessage parameters
$mailParams = @{
SmtpServer = 'smtp.office365.com'
Port = '587' # or '25' if not using TLS
UseSSL = $true ## or not if using non-TLS
Credential = $credential
From = 'sender@yourdomain.com'
To = 'recipient@yourdomain.com', 'recipient@NotYourDomain.com'
Subject = "SMTP Client Submission - $(Get-Date -Format g)"
Body = 'This is a test email using SMTP Client Submission'
DeliveryNotificationOption = 'OnFailure', 'OnSuccess'
}
## Send the message
Send-MailMessage @mailParams The direct send way:
## Build parameters
$mailParams = @{
SmtpServer = 'yourtenantMX.mail.protection.outlook.com'
Port = '25'
UseSSL = $true
From = 'sender@yourdomain.com'
To = 'recipient@yourdomain.com'
Subject = "Direct Send $(Get-Date -Format g)"
Body = 'This is a test email using Direct Send'
DeliveryNotificationOption = 'OnFailure', 'OnSuccess'
}
## Send the email
Send-MailMessage @mailParams