How to Configure DBMail in SQL Server - MS SQL Server DBA Tutorial

In this video you will learn how to configure DBMail in SQL Server using SQL Server Management studio as well as using T-SQL. It also explains how to configure Google smtp server as dbmail account in SQL Server using SQL Server management studio as well as T-SQL Script. It illustrates the smtp server configuration both for Exchange as well as google, what is the port google smtp server uses as well as port number of Microsoft Exchange Server. Step by step dbmail profile configuration as well as account setup. It also shows how to delete dbmail profile and account in sql server.

Script to Configure Database Mail in SQL Server by using Google Account

 sp_configure 'show advanced options',1


sp_configure 'Database Mail XPs',1 
--sp_configure 'SQL Mail XPs',0


--CREATE Profile [Techbrothers]
EXECUTE msdb.dbo.sysmail_add_profile_sp
@profile_name = 'Techbrothers',
@description  = 'EmailNotification';
--CREATE Account [TechBrothers]
EXECUTE msdb.dbo.sysmail_add_account_sp
@account_name            = 'TechBrothers',
@email_address           = '',
@display_name            = 'TechBrothers',
@replyto_address         = '',
@description             = 'Email Notification',
@mailserver_name         = '',
@mailserver_type         = 'SMTP',
@port                    = '587',
@username                = 'Techbrotherssqlage',
@password                = 'GiveCorrectPassword', 
@use_default_credentials =  0 ,
@enable_ssl              =  1 ;
-- Associate Account [TechBrothers] to Profile [Techbrothers]
EXECUTE msdb.dbo.sysmail_add_profileaccount_sp
@profile_name = 'Techbrothers',
@account_name = 'TechBrothers',
@sequence_number = 1 ;
How to Configure DBMail in SQL Server

No comments:

Post a Comment