Setup Database Mail

SQL Server includes a great feature known as Database Mail. This post provides a quick script showing how to setup Database Mail without requiring you to click through a cumbersome user interface. The first part of the script needs to be customized by you so emails will be sent to the correct address.

The Fair Ophelia by Benjamin West - more direct than a database mail setup!

The Fair Ophelia by Benjamin West – more direct than a database mail setup!

The @EmailUsername and @EmailPassword variables should be set to NULL if your email server doesn’t require you to sign in to send an email. If sign-in is required, ensure you use a valid email address and password. The @MailServerPort is typically either 25 or 465.

This query shows the Database Mail Log. Use it to check if the test email was sent correctly.

Check out the rest of our posts on configuring SQL Server. Click here for details from Microsoft about Database Mail.