Database Mail Architecture

Database Mail consists of the following main components:

  • Configuration and security components
    Database Mail stores configuration and security information in the msdb database. Configuration and security objects create profiles and accounts used by Database Mail.
  • Messaging components
    The msdb database acts as the mail-host database that holds the messaging objects that Database Mail uses to send e-mail. These objects include the sp_send_dbmail stored procedure and the data structures that hold information about messages.
  • Database Mail executable
    The Database Mail executable is an external program that reads from a queue in the msdb database and sends messages to e-mail servers.
  • Logging and auditing components
    Database Mail records logging information in the msdb database and the Microsoft Windows application event log.

You do not have to have a complete understanding of the Database Mail architecture to use Database Mail effectively. However, understanding the Database Mail components and how the components interact might help you design your applications and troubleshoot any problems that may occur.

The following illustration shows an overview of the Database Mail architecture.

msdb sends messages to an SMTP mail server

Database Mail is designed on a queued architecture that uses service broker technologies. When users execute sp_send_dbmail, the stored procedure inserts an item into the mail queue and creates a record that contains the e-mail message. Inserting the new entry in the mail queue starts the external Database Mail process (DatabaseMail90.exe). The external process reads the e-mail information and sends the e-mail message to the appropriate e-mail server or servers. The external process inserts an item in the Status queue for the outcome of the send operation. Inserting the new entry in the status queue starts an internal stored procedure that updates the status of the e-mail message. Besides storing the sent, or unsent, e-mail message, Database Mail also records any e-mail attachments in the system tables. Database Mail views provide the status of messages for troubleshooting, and stored procedures allow for administration of the Database Mail queue.

Only members of the DatabaseMailUserRole in the msdb database can execute sp_send_dbmail.

In This Section

See Also

Tasks

Troubleshooting Database Mail

Concepts

Database Mail Configuration Objects
Mail Host Database
Database Mail External Program

Other Resources

Database Mail Views (Transact-SQL)
Database Mail and SQL Mail Stored Procedures (Transact-SQL)

Help and Information

Getting SQL Server 2005 Assistance

Change History

Release History

5 December 2005

New content:
  • The illustration that shows the Database Mail architecture.