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.
Step 1: Get the SMTP settings for your Exchange online server
1- Go to the address http://dev.office.com to sign up for a trial account for office 365.
In this case the Server settings are noted as it will be used in the next step.
Step 2: Install and configure an On-prem SMTP server
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.
2- Open the IIS 6.0 management console. Right click on the SMTP server and open the properties window
7- Click “Ok” twice to apply the settings on the SMTP local server.
Step 3: Configure the SQL Mail
1- Open the SQL management studio and connect to your local server
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.