Configuring Database Mail in Microsoft SQL Server

PowerADM.com / SQL Server / Configuring Database Mail in Microsoft SQL Server

The Database Mail component is used in Microsoft SQL Server to send an SMTP notification to an administrator’s mailbox. You can enable and configure Database Mail to receive various email notifications about events on the MSSQL server.

  1. Run the Microsoft SQL Server Management Studio and connect to your MSSQL instance;
  2. Expand Management -> Database Mail;
  3. Right-click and select Configure Database Mail; Configure Database Mail on Sql Server 2019/2017/2014
  4. This will run the Database Mail Configuration Wizard. Select Set up Database Mail by performing the following tasks; Set up Database Mail by performing the following tasks
  5. Create a new profile and specify the SMTP connection parameters: e-mail address, SMTP server address, TCP port, authentication settings, etc. If you have a relay configured to forward e-mail, you can enable anonymous authentication on it for the IP address of your SQL Server host. You can also create a smart host with postfix to send an e-mail via Microsoft (Office) 365; SQL Server: SMTP connection settings
  6. Set this SMTP profile as default;
  7. Set the following options in the Configure System Mail Parameters:

Logging Level: Normal

Account Retry Delay (seconds): 3600

Database Mail Server options

Now you can send a test e-mail message. Right-click Database Mail and select Send Test E-mail.

Send Test E-mail

Specify the recipient’s email address and check that the test email was successfully delivered to the user’s mailbox.

You can also send an e-mail using a simple T-SQL query:

EXEC msdb.dbo.sp_send_dbmail
@profile_name = 'Notifications',
@recipients = 'target@contoso.com',
@body = 'Check database mail configuration.',
@subject = 'MSSQL Test Message';
GO
Leave a Reply

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