2014-04-05 36 views
0

我在SQL Server 2012和SQL Server 2008上執行了以下腳本。我收到了一封從SQL Server 2012發送但未從SQL Server 2008發送的電子郵件。數據庫電子郵件在sql server 2008中不起作用,但在sql server 2012中起作用

EXECUTE msdb.dbo.sysmail_add_account_sp 
@account_name = 'my_account_name', 
@email_address = '[email protected]', 
@display_name = 'Mail From SQL Server',  
@description = 'sending email via gmail account', 
@mailserver_name = 'smtp.gmail.com',  
@port = 587, 
@username = '[email protected]', 
@password = 'my-password',  
@enable_ssl = 1 

EXECUTE msdb.dbo.sysmail_add_profile_sp 
    @profile_name = 'my email profile', 
    @description = 'Profile used for XXX emails.' 

EXECUTE msdb.dbo.sysmail_add_profileaccount_sp 
@profile_name = 'my email profile', 
@account_name = 'my_account_name', 
@sequence_number = 1 ; 


EXECUTE msdb.dbo.sysmail_add_principalprofile_sp 
@principal_name = 'public', 
@profile_name = 'my email profile', 
@is_default = 1 ; 

exec msdb.dbo.sp_configure 'show advanced options', 1; 
GO 
RECONFIGURE; 
GO 
exec msdb.dbo.sp_configure 'Database Mail XPs', 1; 
GO 
RECONFIGURE 
GO 

exec msdb.dbo.sp_send_dbmail 
@profile_name = 'my email profile', 
@recipients = '[email protected]', 
@subject = 'Mail Test', 
@body = 'Mail Sent Successfully', 
@body_format = 'text' 

使用SQL Server 2008 for Database Mail時出現此錯誤。

The mail could not be sent to the recipients because of the mail server failure.(Sending Mail using Account 6 (2014-04-05T11:39:19). Exception Message: Could not connect to mail server. (A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 74.125.25.109:587).) 

在此先感謝..

+1

可能是防火牆問題? – dean

+0

像@dean所述,但不在服務器級別。檢查您的SQLMail設置並確保用於連接到郵件服務器的憑證是正確的,並且尚未被Policy'd鎖定到鎖定狀態。我通常將郵件帳戶設置爲不遵守網絡策略密碼保留並輸入32個字符長度的混合模式密碼。從SQLMail開始並按照你的方式工作。 – GoldBishop

+0

這些在不同的主機上還是隻是不同的SQL實例?你能否從故障服務器ping SMTP服務器?你能否從故障服務器上TELNET 25'? (防火牆測試) –

回答

0

我不存在腳本中的任何問題。大多數情況下可能會發出「我的電子郵件配置文件」郵件服比較您在2008年創建的配置文件和20012特別郵件服務器IP和憑證。從那裏你可能會得到提示。

相關問題