How to test Office 365 SMTP server using PowerShell

Office 365 supports SMTP relay for authenticated accounts using TLS encryption.

Testing SMTP access is traditionally done using Telnet, but that’s not always an option when using Office 365 due to the authentication requirement.

Fortunately it’s easy to use PowerShell to accomplish the same thing.

How to test SMTP server using PowerShell:

Capture and store the Office 365 credentials for the account you intend to use for SMTP auth:

$msolcred = get-credential | save the credential of from address

Use the stored credentials to send a test message from to, over port 587 (Encrypted w/ SSL):

Send-MailMessage –From –To –Subject “Test Email” –Body “Test SMTP Relay Service” -SmtpServer -Credential $msolcred -UseSsl -Port 587

Give user mailbox rights on Exchange Hosted – BPOS

To give a user full mailbox rights, to be able to send meeting requests as another user do the following:

1. Open Migration Command Shell

2. Type: Add-MSOnlineMailPermission –Identity UserName1@DomainName -TrustedUser UserName2@DomainName -GrantFullAccess $True

Where username1 is the mailbox that you want to give Username2 permission to

3. Enter the proper admin credentials and make sure that the command shell replies with Successfully granted user account full access permission to mailbox

How to set up a forwarder – Microsoft Online Services

1. Download MOS Migration tool from below url :
Microsoft Online Services Migration Tools (32 bit)

Microsoft Online Services Migration Tools (64 bit)

2. Log in to Administration Center for domain in BPOS-S and create a contact for the email address to whom you want to forward emails.

3. Launch the ‘Migration Command Shell’ from your programs folder.

4. Use the below cmdlet to set external forwarding.

Set-MSOnlineAlternateRecipient -Identity <email address of your hosted account> -AlternateRecipient <email address to forward to> -DeliverToBoth $true

Example: Set-MSOnlineAlternateRecipient -Identity -AlternateRecipient -DeliverToBoth $true

*Note: The ‘$true’ on the end means it will leave a copy and forward. Change to ‘$false’ and it will only forward and not fill up mailbox.

*Note: If you want to remove a forwarder:

Clear-MSOnlineAlternateRecipient -Identity <email of hosted account>

Example: Clear-MSOnlineAlternateRecipient -Identity

Connecting a Mobile device to Microsoft Exchange Online

Had some trouble recently getting clients setup with Microsoft Exchange Online services on a mobile device. Here’s the settings that worked for me.

Server: (Do no included the HTTPS:\ portion of address)
Domain: Should be left blank
Password: ******** (The users BPOS/Exchange Online password)

Email account:
Web Access URL: (be sure to include the https:// and trailing /owa)
Password: ******** (The users BPOS/Exchange Online password)
Mailbox Name: user (just the prefix of their email address)

BPOS – Exchange Hosted important Shell Commands

To add mailbox permissions to other users in Microsoft Exchange Hosted Services (BPOS).

Add-MSOnlineMailPermission -Identity -TrustedUser –GrantFullAccess True –GrantSendAs True

Get Mailbox size settings from Microsoft Exchange Hosted Services

Get-XsHostedExchangeMailbox -SourceServer -SourceIdentity -SourceAdminCredential $cred -SourceDetail Full [Read more…]