So you need a simple SMTP relay test for Office 365
Introduction
I have been doing a ton of Exchange migrations lately and setting up internal IIS relays to smarthost to Office 365. In this I have found many issues with firewalls and various settings IT managers like to do to keep email traffic limited. In this I have had to figure out ways to test SMTP from telnet to PowerShell and this one is my favorite so I thought I would share.
Steps (4 total)
1
Open PowerShell
Right Click on PowerShell and Run As Administrator
2
Store your Office 365 Mailbox Credentials
get-credential will prompt you for the Office 365 relay mailbox creds. you need to store this in a variable so you can call it as one bit in the next command line.
$relaycreds = get-credential
3
Use Send-MailMessage PowerShell Command
now we can use the creds above to send a test email message using the Send-MailMessage command. [email protected] to the same user #you just stored the relaycreds in step one. [email protected] to another email address you have under your control so you can see it relay.
Send-MailMessage –From [email protected] –To [email protected] –Subject “Test Email” –Body “Test SMTP Relay Service” -SmtpServer smtp.office365.com -Credential $relaycreds -UseSsl -Port 587
4
Test the SMTP Relay
use the same command with a few changes to test the SMTP relay now.Do this from the server with IIS6 SMTP relay on or change localhost to the FQDN of your choice.
Send-MailMessage –From [email protected] –To [email protected] –Subject “Test Email” –Body “Test SMTP Relay Service” -SmtpServer localhost -Port 25
Conclusion
So really simple way to send emails now and you can see also from this command the ability to email from a scheduled task attached to event triggers. This will help you monitor your windows servers for those specific events that you care about.
Good luck