我在 MailEnable 中将 SMTP 电子邮件中继到远程域时遇到问题,需要一些帮助来确定我在服务器设置中到底缺少什么。
我的设置实际上工作正常,直到昨天我向服务器的 DNS 设置添加了 SPF 记录。然后从昨晚开始(系统下次尝试发送自动电子邮件时),发送到远程地址的电子邮件开始失败。据我所知,我正在对 SMTP 调用的入站部分进行身份验证,但是当它尝试连接出站以将消息发送到其他服务器时,它的表现就像我尚未经过身份验证。
背景:这是我自己的服务器,从托管公司租用的。我可以访问 IIS/Plesk/MailEnable 中站点的所有设置。每次我自定义编写的 VB.NET 应用程序尝试将电子邮件发送到我自己域中的另一个地址时,它都能正常工作。每次我的应用程序尝试将同一封电子邮件发送到远程域上的地址时,我都会收到来自 [email protected] 的回复电子邮件。具有以下内容:
MailEnable: Message could not be delivered to some recipients.
The following recipient(s) could not be reached:
Recipient: [SMTP:<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="e792948295a788938f829583888a868e89c984888a" rel="noreferrer noopener nofollow">[email protected]</a>]
Reason: 551 This mail server requires authentication before sending mail from a locally hosted domain. Please reconfigure your mail client to authenticate before sending mail.
我编写了一个简单的 VB.NET 测试程序来尝试调试此程序:
Dim replyTo As New System.Net.Mail.MailAddress("<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="90feffbde2f5e0fce9d0fde9f4fffdf1f9febef3fffd" rel="noreferrer noopener nofollow">[email protected]</a>", "MyUser")
Dim subject As String = "Test subject"
Dim SendTo As String = "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="4d383e283f0d223925283f2922202c2423632e2220" rel="noreferrer noopener nofollow">[email protected]</a>"
Dim body As String = "This is the email."
Dim message As New System.Net.Mail.MailMessage
message.From = New System.Net.Mail.MailAddress("<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="8ae4e5a7f8effae6f3cae7f3eee5e7ebe3e4a4e9e5e7" rel="noreferrer noopener nofollow">[email protected]</a>", "MyUser")
message.ReplyToList.Add(replyTo)
message.BodyEncoding = System.Text.Encoding.ASCII
message.IsBodyHtml = True
message.Subject = subject
message.Bcc.Add("<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="7914001d16141810173b3a3a3914001d1614181017571a1614" rel="noreferrer noopener nofollow">[email protected]</a>")
message.Body = body
Dim smtp As New System.Net.Mail.SmtpClient("mydomain.com")
Dim smtpCredential As System.Net.NetworkCredential = New System.Net.NetworkCredential("<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="9af4f5b7e8ffeaf6e3daf7e3fef5f7fbf3f4b4f9f5f7" rel="noreferrer noopener nofollow">[email protected]</a>", "password")
smtp.UseDefaultCredentials = False
smtp.Credentials = smtpCredential
smtp.Port = 587
smtp.Send(message)
在 MailEnable 中,我有:
- 激活端口 587 并选中需要身份验证的复选框 在允许通过端口提交之前。再说一遍,上面的 当我发送到某个地址时,程序可以运行(通过端口 587) @mydomain.com,但发送到 @otherdomain.com 的任何内容仍然失败。
- 在“中继”选项卡下,添加了“允许特权中继”中的条目
IP范围”选项为每个127.0.0.1,内部网络IP
服务器的地址,以及服务器的外部IP地址。 (允许经过身份验证的用户中继的选项已经选中,并且仍在选中)
为了完整起见,以下是昨天在 DNS 中设置的 SPF 记录:
v=spf1 a mx ipv4:75.XX.XX.XX include:_spf.google.com -all
MailEnable 还在服务器的根驱动器上创建了一个名为 SMTP-IN-TOP.TXT 的文件,用于记录传入的身份验证的最高计数,我看到我的所有尝试都计入此文件中:
Recent Top Users Authentications During Previous Hour
<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="781617550a1d0814013815011c1715191116561b1715" rel="noreferrer noopener nofollow">[email protected]</a> 4
最后,这里是来自 MailEnable 的事件和调试日志,显示了一次事务尝试:
事件:
09/01/13 15:07:26 SMTP-IN 5300BA9154CC413AAD202DE4FBA6CB71.MAI 596 75.XX.XX.XX 220 mydomain.com ESMTP MailEnable Service, Version: 7.0-- ready at 09/01/13 15:07:26 0 0
09/01/13 15:07:26 SMTP-IN 5300BA9154CC413AAD202DE4FBA6CB71.MAI 596 75.XX.XX.XX EHLO EHLO mydomain-web-01 250-mydomain.com [75.XX.XX.XX], this server offers 4 extensions 127 21
09/01/13 15:07:26 SMTP-IN 5300BA9154CC413AAD202DE4FBA6CB71.MAI 596 75.XX.XX.XX AUTH {blank} 334 UGFzc3dvcmQ6 18 41 <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="294746045b4c5945506944504d4644484047074a4644" rel="noreferrer noopener nofollow">[email protected]</a>
09/01/13 15:07:26 SMTP-IN 5300BA9154CC413AAD202DE4FBA6CB71.MAI 596 75.XX.XX.XX AUTH d29iVFY= 235 Authenticated 19 10 <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="a2cccd8fd0c7d2cedbe2cfdbc6cdcfc3cbcc8cc1cdcf" rel="noreferrer noopener nofollow">[email protected]</a>
09/01/13 15:07:26 SMTP-IN 5300BA9154CC413AAD202DE4FBA6CB71.MAI 596 75.XX.XX.XX MAIL MAIL FROM:<<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="cca2a3e1bea9bca0b58ca1b5a8a3a1ada5a2e2afa3a1" rel="noreferrer noopener nofollow">[email protected]</a>> 250 Requested mail action okay, completed 43 34 <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="6709084a1502170b1e270a1e03080a060e094904080a" rel="noreferrer noopener nofollow">[email protected]</a>
09/01/13 15:07:26 SMTP-IN 5300BA9154CC413AAD202DE4FBA6CB71.MAI 596 75.XX.XX.XX RCPT RCPT TO:<<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="78191c1915560c190114170a38170c101d0a1c1715191116561b1715" rel="noreferrer noopener nofollow">[email protected]</a>> 250 Requested mail action okay, completed 43 36 <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="2f4140025d4a5f43566f42564b40424e4641014c4042" rel="noreferrer noopener nofollow">[email protected]</a>
09/01/13 15:07:26 SMTP-IN 5300BA9154CC413AAD202DE4FBA6CB71.MAI 596 75.XX.XX.XX RCPT RCPT TO:<<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="177a6e73787a767e79555454577a6e73787a767e793974787a" rel="noreferrer noopener nofollow">[email protected]</a>> 250 Requested mail action okay, completed 43 34 <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="deb0b1f3acbbaeb2a79eb3a7bab1b3bfb7b0f0bdb1b3" rel="noreferrer noopener nofollow">[email protected]</a>
09/01/13 15:07:26 SMTP-IN 5300BA9154CC413AAD202DE4FBA6CB71.MAI 596 75.XX.XX.XX DATA DATA 354 Start mail input; end with <CRLF>.<CRLF> 46 6 <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="1c7273316e796c70655c71657873717d7572327f7371" rel="noreferrer noopener nofollow">[email protected]</a>
09/01/13 15:07:27 SMTP-OU D65C7059FE274FBCBA296953ABA4221F.MAI 780 50.XX.XX.XX CONN 220 recipientserver.com ESMTP MailEnable Service, Version: 6.53-- ready at 09/01/13 15:07:26 0 86
09/01/13 15:07:27 SMTP-OU D65C7059FE274FBCBA296953ABA4221F.MAI 780 50.XX.XX.XX EHLO EHLO mydomain.com 250-recipientserver.com [75.XX.XX.XX], this server offers 4 extensions 18 127
09/01/13 15:07:27 SMTP-OU D65C7059FE274FBCBA296953ABA4221F.MAI 780 50.XX.XX.XX MAIL MAIL FROM:<<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="0f6160227d6a7f63764f62766b60626e6661216c6062" rel="noreferrer noopener nofollow">[email protected]</a>> SIZE=423 551 This mail server requires authentication before sending mail from a locally hosted domain. Please reconfigure your mail client to authenticate before sending mail. 43 169
09/01/13 15:07:27 SMTP-OU D65C7059FE274FBCBA296953ABA4221F.MAI 780 50.XX.XX.XX QUIT QUIT 221 Service closing transmission channel 6 42
09/01/13 15:07:28 SMTP-IN 8E182A43292745538949A1160E407982.MAI 780 127.0.0.1 220 mydomain.com ESMTP MailEnable Service, Version: 7.0-- ready at 09/01/13 15:07:28 0 0
09/01/13 15:07:28 SMTP-OU D65C7059FE274FBCBA296953ABA4221F.MAI 576 127.0.0.1 CONN 220 mydomain.com ESMTP MailEnable Service, Version: 7.0-- ready at 09/01/13 15:07:28 0 85
09/01/13 15:07:28 SMTP-IN 8E182A43292745538949A1160E407982.MAI 780 127.0.0.1 EHLO EHLO mydomain.com 250-mydomain.com [127.0.0.1], this server offers 4 extensions 123 18
09/01/13 15:07:28 SMTP-OU D65C7059FE274FBCBA296953ABA4221F.MAI 576 127.0.0.1 EHLO EHLO mydomain.com 250-mydomain.com [127.0.0.1], this server offers 4 extensions 18 123
09/01/13 15:07:28 SMTP-IN 8E182A43292745538949A1160E407982.MAI 780 127.0.0.1 MAIL MAIL FROM:<> SIZE=1052 250 Requested mail action okay, completed 43 24
09/01/13 15:07:28 SMTP-OU D65C7059FE274FBCBA296953ABA4221F.MAI 576 127.0.0.1 MAIL MAIL FROM:<> SIZE=1052 250 Requested mail action okay, completed 24 43
09/01/13 15:07:28 SMTP-IN 8E182A43292745538949A1160E407982.MAI 780 127.0.0.1 RCPT RCPT TO:<<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="610f0e4c1304110d18210c18050e0c00080f4f020e0c" rel="noreferrer noopener nofollow">[email protected]</a>> 250 Requested mail action okay, completed 43 32
09/01/13 15:07:28 SMTP-OU D65C7059FE274FBCBA296953ABA4221F.MAI 576 127.0.0.1 RCPT RCPT TO:<<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="ea8485c7988f9a8693aa87938e85878b8384c4898587" rel="noreferrer noopener nofollow">[email protected]</a>> 250 Requested mail action okay, completed 32 43
09/01/13 15:07:28 SMTP-IN 8E182A43292745538949A1160E407982.MAI 780 127.0.0.1 DATA DATA 354 Start mail input; end with <CRLF>.<CRLF> 46 6
09/01/13 15:07:28 SMTP-OU D65C7059FE274FBCBA296953ABA4221F.MAI 576 127.0.0.1 DATA DATA 354 Start mail input; end with <CRLF>.<CRLF> 6 46
09/01/13 15:07:28 SMTP-OU D65C7059FE274FBCBA296953ABA4221F.MAI 576 127.0.0.1 DATE 250 Requested mail action okay, completed 1063 43
09/01/13 15:07:28 SMTP-IN 05D1026706304C7F941CD6348057CC71.MAI 780 127.0.0.1 QUIT QUIT 221 Service closing transmission channel 42 6
09/01/13 15:07:28 SMTP-OU D65C7059FE274FBCBA296953ABA4221F.MAI 576 127.0.0.1 QUIT QUIT 221 Service closing transmission channel 6 42
调试:
09/01/13 15:07:26 ME-I0135: Authenticating User:<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="781617550a1d0814013815011c1715191116561b1715" rel="noreferrer noopener nofollow">[email protected]</a> using Authentication Provider Credentials
09/01/13 15:07:26 ME-I0107: [596] Relay Granted: Sender IP (75.xx.xx.xx) is within an authorized IP range.
09/01/13 15:07:26 ME-I0101: [596] Local Delivery: Address ([SMTP:<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="c5a8bca1aaa8a4acab87868685a8bca1aaa8a4acabeba6aaa8" rel="noreferrer noopener nofollow">[email protected]</a>]) is local.
09/01/13 15:07:26 ME-I0149: [596] 5300BA9154CC413AAD202DE4FBA6CB71.MAI was received successfully and delivery thread was initiated
09/01/13 15:07:26 ME-E0070: (recv) socket [596] error during [DATA] command from host 75.xx.xx.xx. Socket was disconnected - Error: (10054)
09/01/13 15:07:26 ME-I0074: [596] (Debug) End of conversation
09/01/13 15:07:27 ME-I0018: [2B8847ABCC1242EDBF3417D32DA6DB59.MAI] Outbound message from ([SMTP:<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="c7a9a8eab5a2b7abbe87aabea3a8aaa6aea9e9a4a8aa" rel="noreferrer noopener nofollow">[email protected]</a>]) requeued as [D65C7059FE274FBCBA296953ABA4221F.MAI] to the target domain [otherdomain.com]
09/01/13 15:07:27 ME-I0123: Domain [otherdomain.com] has MX list [mail.otherdomain.com]
09/01/13 15:07:27 ME-I0026: [D65C7059FE274FBCBA296953ABA4221F.MAI] Sending message
09/01/13 15:07:27 ME-IXXXX: [D65C7059FE274FBCBA296953ABA4221F.MAI] DNS resolved to the following record: IP Address=50.XX.XX.XX, Family=2, Type=1, Protocol=6
09/01/13 15:07:27 ME-IXXXX: [D65C7059FE274FBCBA296953ABA4221F.MAI] Remote server returned a response indicating a permanent error. Server Response: (551 This mail server requires authentication before sending mail from a locally hosted domain. Please reconfigure your mail client to authenticate before sending mail.**)
09/01/13 15:07:27 ME-E0036: [D65C7059FE274FBCBA296953ABA4221F.MAI] MAIL FROM command Failed.
09/01/13 15:07:27 ME-E0008: [D65C7059FE274FBCBA296953ABA4221F.MAI] Outbound, could not send the command to the server (error 10038).
09/01/13 15:07:27 ME-E0060: [D65C7059FE274FBCBA296953ABA4221F.MAI] - Message could not be delivered to target domain (otherdomain.com). Message returned to Sender.
09/01/13 15:07:28 ME-I0119: Domain [mydomain.com] has used local loopback address [127.0.0.1] because it is hosted locally.
09/01/13 15:07:28 ME-I0026: [D65C7059FE274FBCBA296953ABA4221F.MAI] Sending message
09/01/13 15:07:28 ME-IXXXX: [D65C7059FE274FBCBA296953ABA4221F.MAI] DNS resolved to the following record: IP Address=127.0.0.1, Family=2, Type=1, Protocol=0
09/01/13 15:07:28 ME-I0101: [780] Local Delivery: Address ([SMTP:<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="147a7b39667164786d54796d707b79757d7a3a777b79" rel="noreferrer noopener nofollow">[email protected]</a>]) is local.
09/01/13 15:07:28 ME-I0149: [780] 8E182A43292745538949A1160E407982.MAI was received successfully and delivery thread was initiated
09/01/13 15:07:28 ME-I0049: [D65C7059FE274FBCBA296953ABA4221F.MAI] Send Completed Successfully
09/01/13 15:07:28 ME-I0074: [780] (Debug) End of conversation
最佳答案
好的,找到问题了。我用来测试问题的“外部”地址实际上位于我们网站在迁移到此专用服务器之前所在的旧服务器上。显然,一旦我们离开它,我们网站的该服务器上的网站/邮件设置就从未被删除。因此,当从我们的新服务器发送到仍托管在旧服务器上的地址时,旧服务器将电子邮件解释为来自未经身份验证的内部地址。
关于email - Plesk/MailEnable SMTP 中继错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18562790/