SQL Server has a feature called database mail. This feature allows the database server to send emails to any external entity using SMTP server. The problem happens if you have installed an on-premise SQL server and an online (Office 365) Exchange server in the cloud. How can you use this Exchange server in the cloud to send database emails?
This blog post provides a complete walkthrough on how to configure this. This is based on the description provided in the KB article http://support.microsoft.com/kb/2600912.
The steps start with the following.
1- Go to the address http://dev.office.com to sign up for a trial account for office 365.
2- After the exchange service is provisioned go to the tenant administration page and click on Outlook
3- Click on the “” icon and then click options
4- Click on “Settings for POP or IMAP access…”
5- Take note of the SMTP server settings
In this case the Server settings are noted as it will be used in the next step.
Next you will need to install an SMTP server in your network to relay to the Exchange online. I am using Windows Server 2012 but you can use any SMTP server.
1- Configure the SMTP server role on your local server.
2- Open the IIS 6.0 management console. Right click on the SMTP server and open the properties window
3- Click on the delivery tab
4- Click “Outbound Security” and enter the login credentials you use for the Exchange online (and office 365) as below Remember to enable “TLS encryption”
5- Click “OK” then click “Advanced”. Enter the SMTP server URL you got in the previous step in the Smart host edit box then click “OK”
6- Click on “Outgoing connections” and set the port correctly to 587 (or depending on your SMTP settings)
7- Click “Ok” twice to apply the settings on the SMTP local server.
1- Open the SQL management studio and connect to your local server
2- Expand the “Management node” and then right click the “Database Mail” node and click “Configure Database Mail”
3- Follow the wizard and the critical part is to configure the access account as per the below screen Please note that you enter the server to send to as localhost and the email address as the email you have on the office 365 Exchange online for the same account you used to configure the delivery configuration of the local SMTP server.
4- Once finished the configuration test the email sending and you should now be able to send emails to any external recipient using you Exchange online as the relay.
I have showed you in this post how to have an on premise SQL server connect and use an in the Cloud Exchange server to be able to send SQL database Emails.
nice post. explained clearly and precisely. Thanks !!
I already tried a few solutions and none work. This are really simple steps I don't know what to do more. I don't receive any error message and the emails are not being delivered. Can anyone help?
SQL Database Mail can be configured to send directly to Office 365 (Exchange online). No need of SMTP relay server.
The server name should be set to outlook.office365.com and the port number to 587. Make sure the check box for "This server requires a secure connection (SSL)" is checked.
Email address must be a valid Office 365 email address.
For SMTP authentication use Basic authentication with your Office 365 email as "User name" and your password (the same you used in the "E-mail address" field).
Make sure your firewall is not blocking outbound connections on port TCP 587.
Marin is correct, however if you use the reporting service for subscriptions, that won't work. You have to use an SMTP Relay Server since SSRS doesn't let you specify the port or encryption method.
Once you have completed the steps Mohamed has here, you have to go in to SQL Server Configuration Tools and then Reporting Services Configuration Manager. Choose email settings and use your Office 365 email address for the From (or it won't work). Use the server name for the name of the SMTP relay server you setup using the above for the SMTP server.
Thank you Marin!
Kept going around in circles with these settings, and yours worked perfectly!