Sitemap
T3CH

Snoop & Learn about Technology, AI, Hacking, Coding, Software, News, Tools, Leaks, Bug Bounty, OSINT & Cybersecurity !¡! But, not limited 2, anything that is Tech Linked…You’ll probably find here ! ;) — Stay ahead with Latest Tech News! -> You write about? Just ping to join !

Database Mail in SQL Server 2022

4 min readAug 22, 2026

--

If you have worked with Microsoft SQL Server and used the SQL Server Management Studio ( SSMS ), you may have noticed there is a service available, which is Database Mail. This service was introduced first in Microsoft SQL Server 2005, though it was deployed since a long time, many DBAs are not utilizing this feature because of depending on 3rd party applications, which can offer you the same functionalities along with other capabilities such as monitoring or visualization tools.

If you are planning to start automating sending emails from the same SQL Server without depending on any external application, we can use Database Mail. Database Mail can be used in the following ways:

  • Sending emails after the SQL jobs / Queries fail or success in SQL Server Agent .
  • When configuring alerts, we can include some recipients to receive email notifications, ex : high CPU usage detected.
  • Query results and reporting : we can send periodic results from an executed queries which cover various insights either on SQL Instance or on SQL Databases, attachments can be added .
  • Application Notification : in some applications, there is notification module for email, this service can be helpful when it comes to sending email notifications regarding some actions / reports to the end users .

Enabling Database Mail

To get started, first open SSMS and then connect to your instance. In the Object Explorer, choose Management > Database Mail as shown here:

Right Click on Database Mail and click on Configure Database Mail.

Choose the first option below to create new SMTP account.

Press enter or click to view image in full size

Once click on Next, you will get the below message box since you are configuring the DB mail for the first time, click on Yes.

In the below image, we need to define a mail profile and within this profile we can define one or multiple SMTP accounts . Click Add.

We gave a name for this profile: AlertsProfile. We need to connect to an SMTP server. I will use my own Gmail account for our demonstration, but a in real world environment, do not use any personal account as there should be a dedicated SMTP server with dedicated account that serves this purpose

Enter your Email Address and Display Name, which is the name will appear in the recipient mail box once receive the email. The Reply Email can be the same as your email, and the SMTP for Google which is smtp.gmail.com

Get Abdellateef Ibrahim’s stories in your inbox

Join Medium for free to get updates from this writer.

Once click on OK, and you have created the first SMTP account, you can add another account if you have for the purpose of failover. If the first SMTP server is down or unreachable, SQL Server will switch to the second SMTP server.

We will keep it as one account in our demonstration.

Press enter or click to view image in full size

Once click on Next, you have the option to select this profile as public to be used by all users in SQL, or private with restriction to specific users or roles, we will use it public one

Press enter or click to view image in full size

Moving Next, we will get the system parameters below:

Press enter or click to view image in full size

The above values are the default ones, here is brief explanation on each one of them :

Press enter or click to view image in full size

After click on Next and Finish, the process of configuring DB mail is done

Press enter or click to view image in full size

Now, let us perform sending test email by apply the following steps :

Right click on Database Mail from Object Explorer and click on “Send Test E-mail”.

Fill in the fields with the required information and click on the Send Test Email button

You will get the below box

There is number 1 appeared. This is the mailitem_id column for the transaction in msdb.dbo.sysmail_allitems DMV.

That’s it; Database Mail is working.

We will deep dive into DB Mail DMVs and how to troubleshoot the issues in different article, and also we will cover the usage for DB mail in more practical ways.

--

--

Abdellateef Ibrahim
Abdellateef Ibrahim

Written by Abdellateef Ibrahim

I am an ambitious guy on specializing in SQL Server and aspiring to grow as a DBA.

T3CH
T3CH

Published in T3CH

Snoop & Learn about Technology, AI, Hacking, Coding, Software, News, Tools, Leaks, Bug Bounty, OSINT & Cybersecurity !¡! But, not limited 2, anything that is Tech Linked…You’ll probably find here ! ;) — Stay ahead with Latest Tech News! -> You write about? Just ping to join !