SQL Server Database Mail Setup

Configure SQL Server to send automated emails for alerts, jobs, and reports.

Database Mail lets SQL Server send emails directly from stored procedures, triggers, or scheduled SQL Agent jobs — perfect for failure alerts, daily reports, or notifying a team when a batch job completes.

Step 1: Enable Database Mail

EXEC sp_configure 'show advanced options', 1;
RECONFIGURE;
EXEC sp_configure 'Database Mail XPs', 1;
RECONFIGURE;

Step 2: Launch the Configuration Wizard

In SSMS, expand Management → right-click Database MailConfigure Database Mail. Choose "Set up Database Mail by performing the following tasks" and create a new profile.

Step 3: Configure an SMTP Account

  • Provide an outgoing mail server address (SMTP)
  • Enter the port number (commonly 587 or 25)
  • Add authentication credentials if your SMTP server requires them

Step 4: Send a Test Email

EXEC msdb.dbo.sp_send_dbmail
  @profile_name = 'MainProfile',
  @recipients = 'you@example.com',
  @subject = 'Database Mail Test',
  @body = 'This is a test email from SQL Server.';
💡 Tip: Check the sysmail_allitems and sysmail_log views in msdb if an email doesn't arrive — they show delivery status and errors.

Common Use Cases

  • Alerting DBAs when a SQL Agent job fails
  • Emailing daily or weekly report summaries automatically
  • Notifying stakeholders when a scheduled ETL process completes

Once configured, Database Mail becomes a lightweight, reliable way to keep your team informed without building a separate notification system.

Ready to go beyond the basics?

Get hands-on training, live mentorship, and placement support with Uncodemy's Data Analytics Course.

Explore Data Analytics Course →