Skip to content

Latest commit

 

History

History
46 lines (33 loc) · 2.81 KB

File metadata and controls

46 lines (33 loc) · 2.81 KB
title Database Mail Log and Audits
description Learn more about Database Mail logs and audit capability.
author WilliamDAssafMSFT
ms.author wiassaf
ms.date 05/16/2025
ms.service sql
ms.topic conceptual
helpviewer_keywords
auditing [SQL Server]
Database Mail [SQL Server], auditing
logs [Database Mail]
audits [SQL Server], Database Mail
Database Mail [SQL Server], logging
monikerRange >=sql-server-2016 || >=sql-server-linux-2017 || =azuresqldb-mi-current

Database Mail log and audits

[!INCLUDE SQL Server SQL MI]

The Database Mail logging functionality is designed to provide a way to isolate and correct problems.

Database Mail stores log information in the msdb database. Information about Database Mail e-mail content, status of e-mails, and any messages received, such as errors are logged by Database Mail and can be used for troubleshooting and auditing purposes.

Database Mail logs

System tables in the msdb database collect information from the Database Mail External Program. Internal tables in the msdb database contain the e-mail messages and attachments sent from Database Mail, together with the current status of each message. Database Mail updates these tables as each message is processed.

  • Database Mail views expose the tables for troubleshooting purposes.

  • Errors appear in the sysmail_event_log (Transact-SQL) view if Service Broker cannot activate the external program, if the external program encounters networking errors or if the Simple Mail Transport Protocol (SMTP) server refuses an e-mail message.

  • When the external program cannot log to the msdb tables, the program logs errors to the Windows Application event log.

Database Mail auditing tasks

Reviewing and managing Database Mail logs Link
Check the delivery status of an individual message Check the Status of E-Mail Messages Sent With Database Mail
Clean up Database Mail messages, attachments, and log entries sysmail_delete_mailitems_sp (Transact-SQL)

sysmail_delete_log_sp (Transact-SQL)
Archive the Database Email Messages and Logs Create a SQL Server Agent Job to Archive Database Mail Messages and Event Logs

Related content