Automatically Configuring SQL Server Database mail


In SQL Server 2005 and higher, there is database wizard to configure the database mail, but no easy way to ask for a script of the current configuration.

Here is a little SQL script which will:

  • activate Database Mail
  • Create a default SMTP profile called sql_alert_profile and attach an SMTP account called account_smtp_public to it
  • Send Test E-Mail
  • Create one or more operators

You may wonder why there is a test mail embedded in this script whereas the contextual menu of the Database mail already provides one. It is just a way to follow the agile principles by providing automated tests.

 

 

 

Leave a comment

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.