如何在专用服务器中使用 IIS6 SMTP 从 ASP.NET 发送邮件?
题
我正在尝试配置运行 ASP.NET 的专用服务器以通过本地 IIS SMTP 服务器发送邮件,但邮件卡在队列文件夹中并且无法传递。
我在 .aspx 页面中使用此代码来测试:
<%@ Page Language="C#" AutoEventWireup="true" %>
<% new System.Net.Mail.SmtpClient("localhost").Send("info@thedomain.com",
"jcarrascal@gmail.com", "testing...", "Hello, world.com"); %>
然后,我将以下内容添加到 Web.config 文件中:
<system.net>
<mailSettings>
<smtp>
<network host="localhost"/>
</smtp>
</mailSettings>
</system.net>
在 IIS 管理器中,我更改了“默认 SMTP 虚拟服务器”属性中的以下内容。
General: [X] Enable Logging
Access / Authentication: [X] Windows Integrated Authentication
Access / Relay Restrictions: (o) Only the list below, Granted 127.0.0.1
Delivery / Advanced: Fully qualified domain name = thedomain.com
最后,我像这样运行 SMTPDiag.exe 工具:
C:\>smtpdiag.exe info@thedomain.com jcarrascal@gmail.com
Searching for Exchange external DNS settings.
Computer name is THEDOMAIN.
Failed to connect to the domain controller. Error: 8007054b
Checking SOA for gmail.com.
Checking external DNS servers.
Checking internal DNS servers.
SOA serial number match: Passed.
Checking local domain records.
Checking MX records using TCP: thedomain.com.
Checking MX records using UDP: thedomain.com.
Both TCP and UDP queries succeeded. Local DNS test passed.
Checking remote domain records.
Checking MX records using TCP: gmail.com.
Checking MX records using UDP: gmail.com.
Both TCP and UDP queries succeeded. Remote DNS test passed.
Checking MX servers listed for jcarrascal@gmail.com.
Connecting to gmail-smtp-in.l.google.com [209.85.199.27] on port 25.
Connecting to the server failed. Error: 10060
Failed to submit mail to gmail-smtp-in.l.google.com.
Connecting to gmail-smtp-in.l.google.com [209.85.199.114] on port 25.
Connecting to the server failed. Error: 10060
Failed to submit mail to gmail-smtp-in.l.google.com.
Connecting to alt2.gmail-smtp-in.l.google.com [209.85.135.27] on port 25.
Connecting to the server failed. Error: 10060
Failed to submit mail to alt2.gmail-smtp-in.l.google.com.
Connecting to alt2.gmail-smtp-in.l.google.com [209.85.135.114] on port 25.
Connecting to the server failed. Error: 10060
Failed to submit mail to alt2.gmail-smtp-in.l.google.com.
Connecting to alt1.gmail-smtp-in.l.google.com [209.85.133.27] on port 25.
Connecting to the server failed. Error: 10060
Failed to submit mail to alt1.gmail-smtp-in.l.google.com.
Connecting to alt2.gmail-smtp-in.l.google.com [74.125.79.27] on port 25.
Connecting to the server failed. Error: 10060
Failed to submit mail to alt2.gmail-smtp-in.l.google.com.
Connecting to alt2.gmail-smtp-in.l.google.com [74.125.79.114] on port 25.
Connecting to the server failed. Error: 10060
Failed to submit mail to alt2.gmail-smtp-in.l.google.com.
Connecting to alt1.gmail-smtp-in.l.google.com [209.85.133.114] on port 25.
Connecting to the server failed. Error: 10060
Failed to submit mail to alt1.gmail-smtp-in.l.google.com.
Connecting to gsmtp183.google.com [64.233.183.27] on port 25.
Connecting to the server failed. Error: 10060
Failed to submit mail to gsmtp183.google.com.
Connecting to gsmtp147.google.com [209.85.147.27] on port 25.
Connecting to the server failed. Error: 10051
Failed to submit mail to gsmtp147.google.com.
我使用的是 ASP.NET 2.0、Windows 2003 Server 及其附带的 IIS。
你能告诉我还需要改变什么来解决这个问题吗?
谢谢
@马特兰特
这是一个专用服务器,这就是我手动安装 SMTP 的原因。
编辑:我使用Exchange使其有些不同,但是它称为“智能主机”中的智能主机,但是在普通的SMTP服务配置中,我认为它称为其他东西。无法确切记住设置名称。
感谢您向我指出智能主机领域。邮件现在正在送达。
在“默认 SMTP 虚拟服务器”属性的“传送”选项卡中,单击“高级”并使用提供商提供的地址填写“智能主机”字段。就我而言(GoDaddy),它是 k2smtpout.secureserver.net。
更多信息请点击这里: http://help.godaddy.com/article/1283
解决方案
我发现最好的办法通常是通过 ISP 的 SMTP 服务器转发邮件,具体取决于有多少电子邮件。减少头痛。看起来这就是您遇到问题的地方,从您的 SMTP 到外部服务器,而不是 asp.net 到您的 SMTP。
只需将您的 SMTP 服务器设置为将其发送到您的 ISP,或者您也可以配置 asp.net 来发送到它。
编辑:我使用交换,所以它有点不同,但它被称为交换中的智能主机,但在普通的 SMTP 服务配置中我认为它被称为其他东西。
我记不清具体的设置名称了。
其他提示
从表面上看,您的防火墙不允许 SMTP(TCP 端口 25)离开您的网络。
两个非常明显的问题(以防万一尚未涵盖)1。windows防火墙被禁用了吗?2.您是否有个人/公司防火墙阻止您的邮件发送?