我在SQL Server 2012和SQL Server 2008上执行了以下脚本。我收到了一封从SQL Server 2012发送但未从SQL Server 2008发送的电子邮件。
EXECUTE msdb.dbo.sysmail_add_account_sp
@account_name = 'my_account_name',
@email_address = 'my-email-address@gmail.com',
@display_name = 'Mail From SQL Server',
@description = 'sending email via gmail account',
@mailserver_name = 'smtp.gmail.com',
@port = 587,
@username = 'my-email-address@gmail.com',
@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 = 'another-gmail@gmail.com',
@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).)
提前致谢..
答案 0 :(得分:0)
我的脚本中没有任何问题。通常可能会发出“我的电子邮件配置文件”的邮件服务器配置文件。比较您在2008年创建的配置文件和20012特殊邮件服务器IP和凭证。从那里你可能会得到提示。