Configuring SQL Server Database Mail

Follow the steps below to configure and enable SQL Server Database Mail on a SQL Server:

  1. In Microsoft SQL Server Management Studio, connect to the SQL Server as the sa user (or a similarly privileged user). In the left hand pane expand the SQL Server node, followed by the "Management" node that appears underneath. Right-click on "Database Mail" and click the "Configure Database Mail" option:




  2. The Database Mail Configuration Wizard welcome screen will appear.




  3. Click "Next >" and choose the option "Set up Database Mail by performing the following tasks:"




  4. Click "Next >". You may be prompted to enable the "Database Mail" feature - if this occurs choose "Yes".




  5. Provide a profile name and description, then click on the "Add..." button to add an SMTP account.




  6. Fill in the details of your SMTP server and user account. If you do not know these, contact your Systems Administrator. The details shown below are for a standard Office 365 email account.




  7. Clicking "OK" on the screen above will return to the wizard "New Profile" screen. The SMTP account should now appear in the SMTP accounts list.




  8. Clicking "Next >" will display the "Manage Profile Security" screen. Profiles are either public or private. A private profile is accessible only to specific users or roles. A public profile allows any user or role with access to the mail host database (msdb) to send e-mail using that profile. We will make this profile public.




  9. Clicking "Next >" will show the "Configure System Parameters" screen. Here various settings such as number of retries, logging, allowed attachments, etc. can be configured. The defaults are OK.




  10. Clicking "Next >" will now display a summary screen. Check the changes and click "Finish" to complete the wizard.




  11. Database Mail will now be installed and configured. A status screen is displayed to show progress, click "Close" when done.




  12. Database Mail should now be tested. In the left hand pane of Microsoft SQL Server Management Studio, expand the SQL Server node, followed by the "Management" node that appears underneath. Right-click on "Database Mail" and click the "Send Test E-Mail..." option:




  13. Fill out some details and then click the "Send Test E-Mail" button.




  14. A confirmation screen will now appear. At this point you should check the inbox of the receipient of the test email to ensure that the email message arrived OK. Click the OK button to finish.




Whilst this guide give a basic walk-through of setting up Database Mail, a more comprehensive guide to configuring Microsoft SQL Server Database Mail is provided by Microsoft here. The Microsoft article provides in depth information regarding the various options and settings that are available.