SQL服务器"无法发送邮件到邮件服务器""发送邮件失败"

Wes*_*ric 6 database-mail sql-server-2008-express

我正在使用64位的MS SQL Server 2008 R2 SP2 Express版.我无法访问数据库邮件设置向导,但Binn目录包含DatabaseMail.exe(v10.50.16600.1)和DatabaseMailengine.dll.

我发现了几个引用"无法发送邮件到邮件服务器",但没有什么用于烦人的通用"发送邮件失败"消息.

我的具体问题是,在哪里可以找出错误信息的含义/原因是什么?如果某种善良的人会想要猜测发生了什么,或者没有继续下去,我会很感激.

来自数据库的设置信息如下:

执行sp_configure'show advanced'

name                    minimum maximum config_value    run_value
show advanced options   0       1       1               1
Run Code Online (Sandbox Code Playgroud)

执行sp_configure'Database Mail XPs'

name                minimum maximum config_value    run_value
Database Mail XPs   0       1       1               1
Run Code Online (Sandbox Code Playgroud)

sysmail_server

account_id  servertype  servername      port username           credential_id   use_default_credentials enable_ssl  flags   timeout last_mod_datetime       last_mod_user
1           SMTP        smtp.gmail.com  465  sqlmail@domain.com 65536           0                       1           0       NULL    2015-11-23 09:34:26.913 WSCORP\username
Run Code Online (Sandbox Code Playgroud)

sys.credentials

credential_id   name                                 credential_identity create_date             modify_date             target_type target_id
65536           F05ADE33-6AA8-45FC-8FF5-A7631831ECB1 sqlmail@domain.com  2015-11-23 09:34:26.913 2015-11-23 09:34:26.913 NULL        NULL
Run Code Online (Sandbox Code Playgroud)

EXEC msdb.sys.sp_helprolemember'DatabaseMailUserRole'

DbRole               MemberName      MemberSID
DatabaseMailUserRole WSCORP\username 0x010500000000000515000000F483990DEADF2220C7DB306E6B040000
Run Code Online (Sandbox Code Playgroud)

EXEC msdb.dbo.sysmail_help_principalprofile_sp

principal_id principal_name  profile_id profile_name is_default
27           WSCORP\username 1          Default      1
Run Code Online (Sandbox Code Playgroud)

执行dbo.sysmail_start_sp

Status
STARTED
Run Code Online (Sandbox Code Playgroud)

sysmail_account

account_id name    description email_address      display_name         replyto_address  last_mod_datetime       last_mod_user
1          SQLMail NULL        sqlmail@domain.com SQLExpresspay12 Mail user@domain.com  2015-11-23 09:34:26.843 WSCORP\username
Run Code Online (Sandbox Code Playgroud)

sysmail_profile

profile_id name    description     last_mod_datetime       last_mod_user
1          Default Default profile 2015-11-23 09:56:58.947 WSCORP\username
Run Code Online (Sandbox Code Playgroud)

sysmail_profileaccount

profile_id  account_id  sequence_number last_mod_datetime       last_mod_user
1           1           1               2015-11-23 10:02:29.867 WSCORP\username
Run Code Online (Sandbox Code Playgroud)

sysmail_servertype

servertype is_incoming  is_outgoing last_mod_datetime       last_mod_user
SMTP       0            1           2010-04-02 17:36:17.340 sa
Run Code Online (Sandbox Code Playgroud)

sysmail_mailitems

mailitem_id profile_id  recipients      copy_recipients blind_copy_recipients subject      from_address reply_to body                                       body_format importance  sensitivity file_attachments attachment_encoding query  execute_query_database  attach_query_result_as_file query_result_header query_result_width  query_result_separator  exclude_query_output append_query_error send_request_date       send_request_user sent_account_id   sent_status sent_date               last_mod_date       last_mod_user
4           1           user@domain.com NULL            NULL                  Test message NULL         NULL     This is the body of the test message.      TEXT        NORMAL      NORMAL      NULL             MIME                NULL   NULL                    0                           1                   256                 0                       0                    0                  2015-11-24 08:23:59.493 WSCORP\username   NULL              2           11/1124/20158 8:25:20   11/24/2015 08:25:20 sa
                                                                                                                   Congratulations, Database Mail Received
                                                                                                                   By you Successfully. 
Run Code Online (Sandbox Code Playgroud)

sysmail_log

log_id  event_type  log_date                description                                             process_id  mailitem_id account_id last_mod_date            last_mod_user
13      1           2015-11-24 08:23:59.787 DatabaseMail process is started                         7324        NULL        NULL       2015-11-24 08:23:59.787  NT AUTHORITY\NETWORK SERVICE
14      1           2015-11-24 08:24:10.270 The mail queue was started by login "WSCORP\username".  NULL        NULL        NULL       2015-11-24 08:24:10.270  WSCORP\username
15      3           2015-11-24 08:24:10.297 The mail could not be sent to the recipients because of 7324        4           NULL       2015-11-24 08:24:10.297  sa
                                             the mail server failure. (Sending Mail using Account 1
                                              (2015-11-24T08:24:10). Exception Message: Cannot send
                                               mails to mail server. (Failure sending mail.). )
Run Code Online (Sandbox Code Playgroud)

Wes*_*ric 5

谷歌希望我使用TLS端口(587),尽管据我所知,没有办法告诉SQL服务器使用TLS.因此,指定SSL并使用TLS端口工作.

  • 此页面 https://support.google.com/a/answer/176600?hl=en 说对 SSL 使用端口 465,对 TLS 使用端口 587。从上面的 sysmail_server 记录中可以看出,我使用了端口 465 并设置了“enable_ssl”标志。答案是保留该标志设置,但将端口更改为 587。 (2认同)
  • 仅供参考... DatabaseMail.exe 是一个使用 [System.Net.Mail.SmtpClient 类](https://learn.microsoft.com/en-us/dotnet/api/system.net.mail) 的 .NET Framework 程序。 smtpclient) 进行邮件传输。`enable_ssl` 列驱动类上的 [EnableSsl 属性](https://learn.microsoft.com/en-us/dotnet/api/system.net.mail.smtpclient.enablessl),该属性决定是否使用端口 25 或端口 587 上的“STARTSSL”(又名显式 SSL)。SmtpClient 类不支持端口 465 上的隐式 SSL。 (2认同)