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.
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.”
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.
Testing if Mail Works
It should be done. To test if it works, right-click on Database Mail and select “Send Test E-mail.”
As seen in the images below, everything is fine, and SQL Server has sent the test email.
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