SQL Server : Database Mail

Enable Database Mail

You can check if Database Mail is enabled using the following command. The setting should be config_value=1 and run_value=1.

sp_configure 'Database Mail XPs'

If Database Mail is not enabled, you can enable it with the following commands.

sp_configure 'Database Mail XPs', 1
reconfigure

Profiles and Accounts

This can be done using the GUI.

  • Right-click on “Management > Database Mail”.
  • Select the “Configure Database Mail” menu option and click the “Next” button on the first screen.
  • Accept the first option “Set up Database Mail by performing the following tasks:” by clicking the “Next” button.
  • On the “New Profile” screen enter a suitable profile name, like “DBA”, and description.
  • Click the “Add” button, then the “New Account” button on the subsequent dialog.
  • Enter a suitable account name, like “DBA”, and SMTP details.
  • Click the “OK” button.
  • Back on the “New Profile” screen, click the “Next” button.
  • If you want to set a default profile, do it here, otherwise, select the profile required and click the “Next” button.
  • If you want to alter the system parameters, do it here, then click the “Next” button.
  • If you are happy with the settings, click the “Finish” button.

You can edit your settings by working through the screens from the “Configure Database Mail” menu option.

Testing Database Mail

You can test the settings as follows.

  • Right-click on “Management > Database Mail”.
  • Select the “Send Test E-Mail” menu option.
  • Pick the profile and enter the message details.
  • Click the “Send Test E-Mail” button.
  • When you are done, click the “Close” button.

For more information see: