The Database Mail feature is only available in the SQL Server Standard edition and higher. In the SQL Server Express edition, unfortunately, it is not available. This feature is useful primarily if you want to send various messages from SQL Server to your email. Typically, this involves various checks, notifications, and alerts.

Finally, this feature is also useful for sending reports stored on the Report Server (SQL Server Reporting Services) at regular intervals – for example, setting up a report to be sent twice a week to specific email addresses.

Configuring Database Mail in SQL Server connected to Gmail

Database E-mail can be configured in two ways – using the graphical interface or using SQL scripts. I will demonstrate the graphical method here. I have created a test email on Gmail with the address “biportaldbmail at gmail.com,” and the goal is to configure Database Mail in SQL Server to send emails using this account.

Where to Configure Database Mail

You can find Database Mail under the Management section -> Database Mail. Double-clicking on it will take you to the Database Mail Configuration Wizard, where you can set everything up.

Database mail - where to find it? Database mail configuration wizard

Configuring Database Mail

On the “Select Configuration Task” screen, select the first option, “Set up Database mail…,” and click “Next.” This will open a window to create a profile, where you will enter the name of your mail profile (you can have multiple profiles). Then, click on “Add SMTP Accounts” and choose “New Account.”

Database mail - select configuration task Database mail - new profile

On the next window, fill in the required information:

  • For Gmail, the server name is smtp.gmail.com. Set the port to 587 and check the “SSL certificate” option.
  • Choose Basic Authentication as the authentication method and enter the email address and password for the account.

Database mail - SMTP Account

Testing if Mail Works

It should be done. To test if it works, right-click on Database Mail and select “Send Test E-mail.”

Database mail - Test email

As seen in the images below, everything is fine, and SQL Server has sent the test email.

Database mail - testovací email došel

More information about configuration can be found on the Microsoft website: https://docs.microsoft.com/en-us/sql/relational-databases/database-mail/configure-database-mail?view=sql-server-2017

Rate this post

Ing. Jan Zedníček - Data Engineer & Controlling

My name is Jan Zedníček and I have been working as a freelancer for many companies for more than 10 years. I used to work as a financial controller, analyst and manager at many different companies in field of banking and manufacturing. When I am not at work, I like playing volleyball, chess, doing a workout in the gym.

🔥 If you found this article helpful, please share it or mention me on your website

Leave a Reply

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