--- title: "Common Errors with Database Mail" description: "Learn how to diagnose and troubleshoot common errors with Database Mail." author: MashaMSFT ms.author: mathoma ms.date: 05/16/2025 ms.service: sql ms.topic: conceptual helpviewer_keywords: - "architecture [SQL Server], Database Mail" - "Database Mail [SQL Server], architecture" - "Database Mail [SQL Server], components" monikerRange: ">=sql-server-2016 || >=sql-server-linux-2017 || =azuresqldb-mi-current" --- # Common errors with database mail [!INCLUDE [SQL Server SQL MI](../../includes/applies-to-version/sql-asdbmi.md)] This article describes some common errors encountered with database mail and their solutions. To run T-SQL commands on your SQL Server instance, use [SQL Server Management Studio (SSMS)](https://aka.ms/ssms), the [MSSQL extension for Visual Studio Code](../../tools/visual-studio-code-extensions/mssql/mssql-extension-visual-studio-code.md), [sqlcmd](../../tools/sqlcmd/sqlcmd-utility.md), or your favorite T-SQL querying tool. ## Could not find stored procedure 'sp_send_dbmail' The [sp_send_dbmail](../system-stored-procedures/sp-send-dbmail-transact-sql.md) stored procedure is installed in the `msdb` database. You must either run `sp_send_dbmail` from the `msdb` database, or specify a three-part name for the stored procedure. Example: ```sql EXEC msdb.dbo.sp_send_dbmail ... ``` Or: ```sql USE msdb; GO EXEC dbo.sp_send_dbmail ... ``` Use [Configure database mail](configure-database-mail.md) to enable and configure database mail. ## Profile not valid There are two possible causes for this message. Either the profile specified does not exist, or the user running [sp_send_dbmail (Transact-SQL)](../system-stored-procedures/sp-send-dbmail-transact-sql.md) does not have permission to access the profile. To check permissions for a profile, run the stored procedure [sysmail_help_principalprofile_sp (Transact-SQL)](../system-stored-procedures/sysmail-help-principalprofile-sp-transact-sql.md) with name of the profile. Use the stored procedure [sysmail_add_principalprofile_sp (Transact-SQL)](../system-stored-procedures/sysmail-help-principalprofile-sp-transact-sql.md) or the [Configure database mail](configure-database-mail.md) to grant permission for a `msdb` user or group to access a profile. ## Permission denied on sp_send_dbmail This article describes how to troubleshoot an error message stating that the user attempting to send Database Mail does not have permission to execute `sp_send_dbmail` The error text is: ```output EXECUTE permission denied on object 'sp_send_dbmail', database 'msdb', schema 'dbo'. ``` To send Database mail, users must be a user in the `msdb` database and a member of the DatabaseMailUserRole database role in the `msdb` database. To add msdb users or groups to this role use SQL Server Management Studio or execute the following statement for the user or role that needs to send Database Mail. ```sql EXEC msdb.dbo.sp_addrolemember @rolename = 'DatabaseMailUserRole' ,@membername = ''; GO ``` For more information, see [sp_addrolemember](../system-stored-procedures/sp-addrolemember-transact-sql.md) and [sp_droprolemember](../system-stored-procedures/sp-droprolemember-transact-sql.md). ## Database mail queued, no entries in sysmail_event_log or Windows Application Event Log Database Mail relies on Service Broker for queuing e-mail messages. If Database Mail is stopped or if Service Broker message delivery is not activated in the `msdb` database, Database Mail queues messages in the database but cannot deliver the messages. In this case, the Service Broker messages remain in the Service Broker Mail queue. Service Broker does not activate the external program, so there are no log entries in `sysmail_event_log` and no updates to the item status in `sysmail_allitems` and the related views. Execute the following statement to check whether Service Broker is enabled in the `msdb` database: ```sql SELECT is_broker_enabled FROM sys.databases WHERE name = 'msdb'; ``` A value of `0` indicates that Service Broker message delivery is not activated in the `msdb` database. To correct the problem, activate Service Broker in the database with the following Transact-SQL command: ```sql USE master ; GO ALTER DATABASE msdb SET ENABLE_BROKER ; GO ``` Database Mail relies on a number of internal stored procedures. To reduce the surface area, these stored procedures are disabled on new installation of SQL Server. To enable these stored procedures, use the [Database Mail XPs (server configuration option)](../../database-engine/configure-windows/database-mail-xps-server-configuration-option.md) of the `sp_configure` system stored procedure, as in the following example: ```sql EXEC sp_configure 'show advanced options', 1; RECONFIGURE; EXEC sp_configure 'Database Mail XPs', 1; RECONFIGURE; EXEC sp_configure 'show advanced options', 0; RECONFIGURE; GO ``` Database Mail might be stopped in the `msdb` database. To check status of Database Mail, execute the following statement: ```sql EXECUTE dbo.sysmail_help_status_sp; ``` To start Database Mail in a mail host database, run the following command in the `msdb` database: ```sql EXECUTE dbo.sysmail_start_sp; ``` Service Broker examines the dialog lifetime for messages when it is activated; therefore, any messages that have been in the Service Broker transmission queue longer than the configured dialog lifetime immediately fails. Database Mail updates the status of failed messages in the [sysmail_allitems](../system-catalog-views/sysmail-allitems-transact-sql.md) and related views. You must decide whether to send the e-mail messages again. For more information about configuring the dialog lifetime that Database Mail uses, see [sysmail_configure_sp](../system-stored-procedures/sysmail-configure-sp-transact-sql.md). ## Next step > [!div class="nextstepaction"] > [General database mail troubleshooting](database-mail-general-troubleshooting.md)