| title | Configure SQL Server Agent Mail to Use Database Mail | ||
|---|---|---|---|
| description | Configure SQL Server Agent mail to use Database Mail | ||
| author | WilliamDAssafMSFT | ||
| ms.author | wiassaf | ||
| ms.date | 05/16/2025 | ||
| ms.service | sql | ||
| ms.topic | conceptual | ||
| helpviewer_keywords |
|
||
| monikerRange | >=sql-server-2016 || >=sql-server-linux-2017 || =azuresqldb-mi-current |
[!INCLUDE SQL Server SQL MI]
This article describes how to configure [!INCLUDEssNoVersion] Agent to use Database Mail to send notification and alerts in [!INCLUDEssnoversion] by using [!INCLUDEssManStudioFull].
- For information on how to enable and configure Database Mail, see Configure database mail.
- For an example using [!INCLUDEtsql], see Create a Database Mail Profile.
- To send e-mail using SQL Agent jobs in [!INCLUDEssazuremi-md], SQL Server Agent can use only one Database Mail profile, and it must be called
AzureManagedInstance_dbmail_profile. For more information and a sample script, see Azure SQL Managed Instance SQL Agent job notifications.
-
Create a Database Mail Account for the [!INCLUDEssNoVersion] Agent service account to use.
-
Create a Database Mail Profile for the [!INCLUDEssNoVersion] Agent service account to use and add the user to the DatabaseMailUserRole database role in the
msdbdatabase. Verify that users properly configured to send mail. -
Set the profile as the default profile for the
msdbdatabase.
The user creating the profiles accounts and executing stored procedures should be a member of the sysadmin fixed server role.
Tip
The following steps aren't necessary in [!INCLUDEssazuremi-md], 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)
-
Connect to the [!INCLUDEssNoVersion] instance.
-
In Object Explorer, expand a [!INCLUDEssNoVersion] instance.
-
Right-click SQL Server Agent, and then select Properties.
-
Select Alert System.
-
Select Enable Mail Profile.
-
In the Mail system list, select Database Mail.
-
In the Mail profile list, select a mail profile for Database Mail.
-
Restart SQL Server Agent.
The following tasks are necessary to complete the configuration of Agent to send alerts and notifications.
-
SQL Agent Alerts can be configured to notify an operator of a particular database event or operating system condition.
-
SQL Agent Operators are aliases for people or groups that can receive notifications, for example by email.