Skip to content
Rishan Solutions
Rishan Solutions
  • PowerApps
  • SharePoint online
    • Uncategorized
    • Uncategorized
  • PowerAutomate
Rishan Solutions
Latest Posts
  • Agentic AI: The Dawn of Autonomous Intelligence Revolutionizing 2025 June 24, 2025
  • Recursive Queries in T-SQL May 7, 2025
  • Generating Test Data with CROSS JOIN May 7, 2025
  • Working with Hierarchical Data May 7, 2025
  • Using TRY_CAST vs CAST May 7, 2025
  • Dynamic SQL Execution with sp_executesql May 7, 2025

Database Mail Configuration

Posted on April 28, 2025April 28, 2025 by Zubair Shaik

Loading

Comprehensive Guide to Configuring Database Mail in SQL Server


Table of Contents

  1. Introduction
  2. Prerequisites
  3. Enabling Database Mail XPs
  4. Accessing the Database Mail Configuration Wizard
  5. Creating a New Database Mail Account
  6. Creating a New Database Mail Profile
  7. Configuring Profile Security
  8. Setting System Parameters
  9. Testing the Configuration
  10. Configuring SQL Server Agent to Use Database Mail
  11. Troubleshooting Common Issues
  12. Best Practices
  13. Conclusion

1. Introduction

Database Mail is a feature in SQL Server that allows the database engine to send e-mail messages to users. This functionality is essential for sending alerts, query results, and notifications. Configuring Database Mail involves setting up accounts, profiles, and system parameters to ensure seamless communication.


2. Prerequisites

Before configuring Database Mail, ensure the following:

  • Permissions: You must be a member of the sysadmin fixed server role to configure Database Mail. To send e-mail, you need to be a member of the DatabaseMailUserRole in the msdb database.
  • SMTP Server Details: Obtain the SMTP server address, port number, and authentication credentials (if required).
  • Network Configuration: Ensure that the SQL Server instance can communicate with the SMTP server over the necessary ports.

3. Enabling Database Mail XPs

By default, Database Mail is disabled. To enable it:

  1. Open SQL Server Management Studio (SSMS).
  2. Connect to your SQL Server instance.
  3. Execute the following T-SQL command: EXEC sp_configure 'show advanced options', 1; RECONFIGURE; EXEC sp_configure 'Database Mail XPs', 1; RECONFIGURE; This enables the extended stored procedures necessary for Database Mail functionality.

4. Accessing the Database Mail Configuration Wizard

To launch the Database Mail Configuration Wizard:

  1. In SSMS, expand the Management node.
  2. Right-click on Database Mail and select Configure Database Mail.
  3. Choose one of the following configuration tasks:
    • Set up Database Mail by performing the following tasks: For a new configuration.
    • Manage Database Mail accounts and profiles: To modify existing configurations.
    • View or change system parameters: To adjust system-wide settings.

5. Creating a New Database Mail Account

A Database Mail account defines the SMTP server settings. To create one:

  1. In the wizard, select Set up Database Mail by performing the following tasks.
  2. On the Select Configuration Task page, choose Create a new account.
  3. Provide the following details:
    • Account Name: A unique name for the account.
    • Description: An optional description.
    • Email Address: The sender’s e-mail address.
    • Display Name: The name that appears in the “From” field.
    • Reply E-mail: The address for replies (optional).
    • SMTP Server: The address of the SMTP server.
    • Port Number: The SMTP server port (default is 25).
    • This server requires a secure connection (SSL): Check if the SMTP server requires SSL.
    • Authentication: Choose the appropriate authentication method:
      • Windows Authentication: Uses the SQL Server service account credentials.
      • Basic Authentication: Requires a username and password.
      • Anonymous Authentication: No credentials required.
  4. Click Next to proceed.

6. Creating a New Database Mail Profile

A profile is a collection of accounts. To create a profile:

  1. On the Manage Profiles page, select Create a new profile.
  2. Provide the following details:
    • Profile Name: A unique name for the profile.
    • Description: An optional description.
  3. On the Add a New Account to Profile page, select the account(s) to include in the profile.
  4. Set the Account Priority to determine the order in which accounts are used.
  5. Click Next to proceed.

7. Configuring Profile Security

Profile security determines which users can use the profile:

  1. On the Manage Profile Security page, select the profile.
  2. Under the Public tab, choose whether all users can use the profile.
  3. Under the Private tab, add specific users or roles that can use the profile.
  4. Click Next to proceed.

8. Setting System Parameters

System parameters control various aspects of Database Mail:

  1. On the Configure System Parameters page, adjust settings such as:
    • Maximum File Size: The maximum size of attachments.
    • Attachment File Extensions: Allowed file types for attachments.
    • Account Retry Attempts: Number of times to retry sending an e-mail.
    • Account Retry Delay: Delay between retry attempts.
  2. Click Next to proceed.

9. Testing the Configuration

To ensure that Database Mail is configured correctly:

  1. On the Complete the Wizard page, select Send Test E-Mail.
  2. Provide the recipient’s e-mail address and click Send.
  3. Check the recipient’s inbox for the test e-mail.

If the e-mail is not received, review the Database Mail Log for errors.


10. Configuring SQL Server Agent to Use Database Mail

To enable SQL Server Agent to send e-mails:

  1. Right-click on SQL Server Agent and select Properties.
  2. On the Alert System page, check Enable Mail Profile.
  3. Select the mail system as Database Mail.
  4. Choose the mail profile to use.
  5. Click OK to save the changes.
  6. Restart the SQL Server Agent service for the changes to take effect.

11. Troubleshooting Common Issues

Common issues and their resolutions:

  • E-mails Not Sent: Verify SMTP server settings and network connectivity.
  • Authentication Errors: Ensure correct credentials are provided.
  • E-mails Stuck in Queue: Check the Database Mail log for errors and resolve any issues.

For detailed troubleshooting steps, refer to the official documentation: (Configure Database Mail – SQL Server | Microsoft Learn)


12. Best Practices

Follow these best practices:

  • Use Secure Connections: Always use SSL/TLS for SMTP communication.
  • Limit Profile Access: Restrict profile access to necessary users.
  • Monitor Logs Regularly: Regularly review the Database Mail log for issues.
  • Test Configuration: Periodically test the e-mail functionality.

Configuring Database Mail in SQL Server is essential for automating e-mail notifications and alerts. By following the steps outlined in this guide, you can set up a reliable e-mail system to enhance your database management tasks.

For more detailed information, refer

Posted Under SQL Serverconfigure database mail configuring SQL Server email database administration Database Mail database mail account database mail best practices database mail configuration database mail error log database mail log database mail parameters database mail profile permissions database mail setup database mail SSL Database Monitoring email automation SQL Server email from SQL Server Agent email SQL Server query results mail profile SQL Server msdb database mail secure email SQL Server send email from SQL Server SQL Agent email alerts SQL DBA tools SQL mail configuration SQL Server SQL Server alerts SQL Server automation SQL Server Connectivity SQL Server Database Mail SQL Server database tools SQL Server email notifications SQL Server email troubleshooting SQL Server job alerts SQL Server mail profile SQL Server mail profile setup SQL Server mail security SQL Server mail service SQL Server mail setup steps SQL Server maintenance notifications SQL Server Management Studio SQL Server monitoring SQL Server notification system SQL Server operator alerts SQL Server proxy email SQL Server SMTP SQL Server SMTP authentication SQL Server system configuration SQL Server test mail SQL Server Troubleshooting SSMS mail configuration T-SQL database mail test database mail

Post navigation

SQL Server Agent and Jobs
Creating and Using Linked Servers

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recent Posts

  • Agentic AI: The Dawn of Autonomous Intelligence Revolutionizing 2025
  • Recursive Queries in T-SQL
  • Generating Test Data with CROSS JOIN
  • Working with Hierarchical Data
  • Using TRY_CAST vs CAST

Recent Comments

  1. Michael Francis on Search , Filter and Lookup in power apps
  2. A WordPress Commenter on Hello world!

Archives

  • June 2025
  • May 2025
  • April 2025
  • March 2025
  • February 2025
  • March 2024
  • November 2023
  • October 2023
  • September 2023
  • August 2023
  • June 2023
  • May 2023
  • April 2023
  • February 2023
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • January 2022

Categories

  • Active Directory
  • AI
  • AngularJS
  • Blockchain
  • Button
  • Buttons
  • Choice Column
  • Cloud
  • Cloud Computing
  • Data Science
  • Distribution List
  • DotNet
  • Dynamics365
  • Excel Desktop
  • Extended Reality (XR) – AR, VR, MR
  • Gallery
  • Icons
  • IoT
  • Java
  • Java Script
  • jQuery
  • Microsoft Teams
  • ML
  • MS Excel
  • MS Office 365
  • MS Word
  • Office 365
  • Outlook
  • PDF File
  • PNP PowerShell
  • Power BI
  • Power Pages
  • Power Platform
  • Power Virtual Agent
  • PowerApps
  • PowerAutomate
  • PowerPoint Desktop
  • PVA
  • Python
  • Quantum Computing
  • Radio button
  • ReactJS
  • Security Groups
  • SharePoint Document library
  • SharePoint online
  • SharePoint onpremise
  • SQL
  • SQL Server
  • Template
  • Uncategorized
  • Variable
  • Visio
  • Visual Studio code
  • Windows
© Rishan Solutions 2025 | Designed by PixaHive.com.
  • Rishan Solutions