Office 365 – Test SMTP on Port 587 using Powershell

Firstly open up Powershell (Must be v3 or greater), then copy/paste the following command,

$creds = get-credential 

When prompted, enter the Office 365 username and password which you plan to run the test from.

Once these credentials are stored in a variable, copy and paste the next snippet replacing the FROM field with your Office365 account that you have just specified in your credentials then specify a valid TO address,

Send-MailMessage –From <O365 email address> –To <Recipient email address> –Subject "Test Email" –Body "Test SMTP Service from Powershell on Port 587" -SmtpServer smtp.office365.com -Credential $creds -UseSsl -Port 587

All being well the email should be successfully delivered.

If you get the following error message when running the command, you need to ensure you are running Powershell version 3 or greater

Send-MailMessage : A parameter cannot be found that matches parameter name ‘Port’.

 

TELNET

You can also use Telnet Because O365 uses TLS You can’t really get far using Telnet on its own besides connecting to the server.

To provide the Username and Password you then have to use base64 encryption and then you could go one step further if you wanted to persevere.
From the command prompt >> Telnet [SMTP Server IP Address]
mail from: [senders e-mail]
You will see: 503 5.5.2 send hello first……. Then type the following
helo bbb
you will see: 250 [server name] …Hello [192.168.1.100- Server name]
mail from : senders_email address
you will see: 250 2.1.0 [senders_email] … Sender OK
rcpt to: [send_to_E-mail]
250 2.1.5 [send_to_E-mail]
Data
354 Start mail input:end with <CRLF>.<CRLF>
Please put your desired message.
/
.
… Check your mailbox, you should receive the mail if everything goes fine..