| title | Send a Test Email with Database Mail | |||
|---|---|---|---|---|
| description | Send a test email with database mail | |||
| author | MashaMSFT | |||
| ms.author | mathoma | |||
| ms.date | 05/16/2025 | |||
| ms.service | sql | |||
| ms.topic | how-to | |||
| helpviewer_keywords |
|
|||
| monikerRange | >=sql-server-2016 || >=sql-server-linux-2017 || =azuresqldb-mi-current |
[!INCLUDE SQL Server SQL MI]
Use the Send Test E-Mail dialog box to test the ability to send mail using a specific profile.
You must be a member of the sysadmin fixed server role to use the Send Test E-Mail dialog box. Users who are not members of the sysadmin fixed server role can test Database Mail using the sp_send_dbmail procedure.
-
Using Object Explorer in SQL Server Management Studio (SSMS), connect to an instance of SQL Server Database Engine where Database Mail is configured, expand Management, right-click Database Mail, and then select Send Test E-Mail. If no Database Mail profiles exist, a dialog prompts the user to create a profile and opens the Database Mail Configuration Wizard.
-
In the Send Test E-Mail dialog box, in the Database Mail Profile box select the profile you want to test.
-
In the To box, type the e-mail name of the recipient of the test e-mail.
-
In the Subject box, type the subject line for the test e-mail. Change the default subject to better identify your e-mail for troubleshooting.
-
In the Body box, type to body of the test e-mail. Change the default subject to better identify your e-mail for troubleshooting.
-
Select Send Test E-Mail to send the test e-mail to the Database Mail queue.
-
Sending the test e-mail opens the Database Mail Test E-Mail dialog box. Make a note of the number displayed in the Sent e-mail box. This is the mailitem_id of the test message. Select OK.
-
On the Toolbar select New Query to open a Query Editor window. Run the following T-SQL statement to determine the status of the test e-mail message:
SELECT * FROM msdb.dbo.sysmail_allitems WHERE mailitem_id = <the mailitem_id from the previous step> ;
The
sent_statuscolumn indicates if the test e-mail message was sent. -
If errors occurred, execute the following statement to view the error message:
SELECT * FROM msdb.dbo.sysmail_event_log WHERE mailitem_id = <the mailitem_id from the previous step> ;