Edit

Share via


Configure SQL Server Agent mail to use Database Mail

Applies to: SQL Server Azure SQL Managed Instance

This article describes how to configure SQL Server Agent to use Database Mail to send notification and alerts in SQL Server by using SQL Server Management Studio.

Prerequisites

  1. Configure database mail.

  2. Create a Database Mail Account for the SQL Server Agent service account to use.

  3. Create a Database Mail Profile for the SQL Server Agent service account to use and add the user to the DatabaseMailUserRole database role in the msdb database. Verify that users properly configured to send mail.

  4. Set the profile as the default profile for the msdb database.

Permissions

The user creating the profiles accounts and executing stored procedures should be a member of the sysadmin fixed server role.

Use SQL Server Management Studio to configure SQL Server Agent to use Database Mail

Tip

The following steps aren't necessary in Azure SQL Managed Instance, which is already configured to look for a profile called AzureManagedInstance_dbmail_profile. For more information and a sample script, see Azure SQL Managed Instance SQL Agent job notifications.

The following steps use SQL Server Management Studio (SSMS)

  1. Connect to the SQL Server instance.

  2. In Object Explorer, expand a SQL Server instance.

  3. Right-click SQL Server Agent, and then select Properties.

  4. Select Alert System.

  5. Select Enable Mail Profile.

  6. In the Mail system list, select Database Mail.

  7. In the Mail profile list, select a mail profile for Database Mail.

  8. Restart SQL Server Agent.

Follow-up tasks

The following tasks are necessary to complete the configuration of Agent to send alerts and notifications.

  • Alerts

    SQL Agent Alerts can be configured to notify an operator of a particular database event or operating system condition.

  • Operators

    SQL Agent Operators are aliases for people or groups that can receive notifications, for example by email.