Configuring SQL Server Database Mail
Follow the steps below to configure and enable SQL Server Database Mail on a SQL Server:
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:
The Database Mail Configuration Wizard welcome screen will appear.
Click "Next >" and choose the option "Set up Database Mail by performing the following tasks:"
Click "Next >". You may be prompted to enable the "Database Mail" feature - if this occurs choose "Yes".
Provide a profile name and description, then click on the "Add..." button to add an SMTP account.
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.
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.
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.
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.
Clicking "Next >" will now display a summary screen. Check the changes and click "Finish" to complete the wizard.
Database Mail will now be installed and configured. A status screen is displayed to show progress, click "Close" when done.
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:
Fill out some details and then click the "Send Test E-Mail" button.
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.