如何使用IIS6 SMTP在专用服务器中从ASP.NET发送邮件?

时间:2021-11-05 14:31:58

I'm trying to configure a dedicated server that runs ASP.NET to send mail through the local IIS SMTP server but mail is getting stuck in the Queue folder and doesn't get delivered.

我正在尝试配置运行ASP.NET的专用服务器以通过本地IIS SMTP服务器发送邮件,但邮件卡在Queue文件夹中并且无法传递。

I'm using this code in an .aspx page to test:

我在.aspx页面中使用此代码来测试:

<%@ Page Language="C#" AutoEventWireup="true" %>

<% new System.Net.Mail.SmtpClient("localhost").Send("info@thedomain.com", 
    "jcarrascal@gmail.com", "testing...", "Hello, world.com"); %>    

Then, I added the following to the Web.config file:

然后,我将以下内容添加到Web.config文件中:

<system.net>
  <mailSettings>
    <smtp>
      <network host="localhost"/>
    </smtp>
  </mailSettings>
</system.net>

In the IIS Manager I've changed the following in the properties of the "Default SMTP Virtual Server".

在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

Finally, I run the SMTPDiag.exe tool like this:

最后,我运行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.

I'm using ASP.NET 2.0, Windows 2003 Server and the IIS that comes with it.

我正在使用ASP.NET 2.0,Windows 2003 Server和它附带的IIS。

Can you tell me what else to change to fix the problem?

你能告诉我还有什么可以改变来解决这个问题吗?

Thanks


@mattlant

This is a dedicated server that's why I'm installing the SMTP manually.

这是一个专用服务器,这就是我手动安装SMTP的原因。

EDIT: I use exchange so its a little different, but its called a smart host in exchange, but in plain SMTP service config i think its called something else. Cant remember exactly the setting name.

编辑:我使用交换所以它有点不同,但它被称为智能主机交换,但在普通的SMTP服务配置我认为它称为其他东西。不记得确切的设置名称。

Thank you for pointing me at the Smart host field. Mail is getting delivered now.

感谢您将我指向智能主机字段。邮件现在正在递送。

In the Default SMTP Virtual Server properties, the Delivery tab, click Advanced and fill the "Smart host" field with the address that your provider gives you. In my case (GoDaddy) it was k2smtpout.secureserver.net.

在“默认SMTP虚拟服务器”属性的“传递”选项卡中,单击“高级”,然后在“智能主机”字段中填写提供商为您提供的地址。在我的情况下(GoDaddy),它是k2smtpout.secureserver.net。

More info here: http://help.godaddy.com/article/1283

更多信息请访问:http://help.godaddy.com/article/1283

3 个解决方案

#1


2  

I find the best thing usually depending on how much email there is, is to just forward the mail through your ISP's SMTP server. Less headaches. Looks like that's where you are having issues, from your SMTP to external servers, not asp.net to your SMTP.

我发现最好的东西通常取决于电子邮件的数量,只是通过ISP的SMTP服务器转发邮件。少说头疼。看起来这就是您遇到问题的地方,从SMTP到外部服务器,而不是asp.net到SMTP。

Just have your SMTP server set to send it to your ISP, or you can configure asp.net to send to it.

只需将您的SMTP服务器设置为发送给您的ISP,或者您可以配置asp.net发送给它。

EDIT: I use exchange so it's a little different, but it's called a smart host in exchange, but in plain SMTP service config I think it's called something else.

编辑:我使用交换,所以它有点不同,但它被称为交换的智能主机,但在普通的SMTP服务配置,我认为它被称为其他东西。

I can't remember exactly the setting name.

我不记得确切的设置名称。

#2


0  

By the looks of things your firewall isn't letting SMTP (TCP port 25) out of your network.

从外观上看,防火墙不允许SMTP(TCP端口25)离开您的网络。

#3


0  

two really obvious questions (just in case they haven't been covered) 1. has windows firewall been disabled? 2. do you have a personal/company firewall that is preventing your mail from being sent?

两个非常明显的问题(以防它们没有被覆盖)1。Windows防火墙被禁用了吗? 2.您是否有个人/公司防火墙阻止您的邮件被发送?

#1


2  

I find the best thing usually depending on how much email there is, is to just forward the mail through your ISP's SMTP server. Less headaches. Looks like that's where you are having issues, from your SMTP to external servers, not asp.net to your SMTP.

我发现最好的东西通常取决于电子邮件的数量,只是通过ISP的SMTP服务器转发邮件。少说头疼。看起来这就是您遇到问题的地方,从SMTP到外部服务器,而不是asp.net到SMTP。

Just have your SMTP server set to send it to your ISP, or you can configure asp.net to send to it.

只需将您的SMTP服务器设置为发送给您的ISP,或者您可以配置asp.net发送给它。

EDIT: I use exchange so it's a little different, but it's called a smart host in exchange, but in plain SMTP service config I think it's called something else.

编辑:我使用交换,所以它有点不同,但它被称为交换的智能主机,但在普通的SMTP服务配置,我认为它被称为其他东西。

I can't remember exactly the setting name.

我不记得确切的设置名称。

#2


0  

By the looks of things your firewall isn't letting SMTP (TCP port 25) out of your network.

从外观上看,防火墙不允许SMTP(TCP端口25)离开您的网络。

#3


0  

two really obvious questions (just in case they haven't been covered) 1. has windows firewall been disabled? 2. do you have a personal/company firewall that is preventing your mail from being sent?

两个非常明显的问题(以防它们没有被覆盖)1。Windows防火墙被禁用了吗? 2.您是否有个人/公司防火墙阻止您的邮件被发送?