MSSQL Create a Database Mail account 메일설정
MSSQL Create a Database Mail account
MSSQL 메일 설정은 MSSQL - 관리 - 데이터베이스 메일에서 클릭해서 하는 방법도 있지만, 그냥 쿼리로 때려박는 방법도 있다.
Mail Server 설정이 중요하니 꼭 확인해야 한다.
Mail Server 가 없다면 naver나 Google 등을 화용하는 방법도 있다.
각 사이트 별 SMTP 설정을 확인해서 진행하면 된다.
-- Create a Database Mail account
EXECUTE msdb.dbo.sysmail_add_account_sp
@account_name = 'test_mail',
@description = 'Main account for Database Mail',
@email_address = 'admin@test.com',
@replyto_address = NULL,
@display_name = 'Test_Mail',
@mailserver_name = 'mail.test.com' ;
-- Create a Database Mail profile
EXECUTE msdb.dbo.sysmail_add_profile_sp
@profile_name = 'test_mail',
@description = 'test_mail' ;
-- Add the account to the profile
EXECUTE msdb.dbo.sysmail_add_profileaccount_sp
@profile_name = 'test_mail',
@account_name = 'test_mail',
@sequence_number =1 ;
-- Grant access to the profile to the DBMailUsers role
EXECUTE msdb.dbo.sysmail_add_principalprofile_sp
@profile_name = 'test_mail',
@principal_name = 'sa',
@is_default = 1 ;
#MSSLQ MAIL #SQL Mail #Mail #Server Mail #SMTP Mail #MSSQL #SQL Server