SQL Server Express 上的 SQL 电子邮件配置

问题描述

我正在尝试配置 sql 数据库邮件发送电子邮件 Gmail 到 Gmail,但我得到: 信息 由于邮件服务器故障,无法将邮件发送给收件人。 (使用帐户 1 发送邮件 (2021-04-14T09:21:14)。异常消息:无法向邮件服务器发送邮件。(发送邮件失败。)。 )

我不知道我做错了什么。

----创建数据库账户----

Use MSDB

go

IF NOT EXISTS(SELECT * FROM msdb.dbo.sysmail_account WHERE  name = 'sqlServer Express') 
  
BEGIN 
    

--CREATE Account [sqlServer Express] 

    
EXECUTE msdb.dbo.sysmail_add_account_sp 
    
@account_name            = 'sqlServer Express',@email_address           = 'sangitar23@gmail.com',@display_name            = 'Audit Partnership',@replyto_address         = '',@description             = '',@mailserver_name         = 'smtp.gmail.com',@mailserver_type         = 'SMTP',@port                    = '587',@username                ='sangitar23@gmail.com',@password                = 'Atlanta2020!',@use_default_credentials =  0,@enable_ssl              =  1 ; 
  
END --IF EXISTS  account
  


  ------  create the database mail profile -------- 
  
Use MSDB

go

IF NOT EXISTS(SELECT * FROM msdb.dbo.sysmail_profile WHERE  name = 'sqlServer Express Edition')  
 
 BEGIN 
 


  
 --CREATE Profile [sqlServer Express Edition] 
   
 EXECUTE msdb.dbo.sysmail_add_profile_sp 
     
 @profile_name = 'sqlServer Express Edition',@description  = 'This db mail account is used by sql Server Express edition.'; 
 
 END --IF EXISTS profile

------------为数据库邮件配置文件分配一个数据库邮件账户--------

Use MSDB

go

IF NOT EXISTS(SELECT * 
             
 FROM msdb.dbo.sysmail_profileaccount pa 
              
  INNER JOIN msdb.dbo.sysmail_profile p ON pa.profile_id = p.profile_id 
              
  INNER JOIN msdb.dbo.sysmail_account a ON pa.account_id = a.account_id   
              
WHERE p.name = 'sqlServer Express Edition' 
              
  AND a.name = 'sqlServer Express')  
  
BEGIN 
   

 -- Associate Account [sqlServer Express] to Profile [sqlServer Express Edition] 
   
 EXECUTE msdb.dbo.sysmail_add_profileaccount_sp 
    
  
@profile_name = 'sqlServer Express Edition',@account_name = 'sqlServer Express',@sequence_number = 1 ; 
 
 

END
  
 
 EXEC msdb.dbo.sp_send_dbmail  
   
 @profile_name = 'sqlServer Express Edition',@recipients = 'sangitarai023@gmail.com',@body = 'Email notification for Audit Partnership SFTP',@subject = ' This email has been sent from sql Server to notify,client uploaded data on the SFTP cite' ;

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)