在Windows Server 2008上的IIS 7下设置SMTP

时间:2021-09-14 18:11:10

Website started life originally under IIS 6 and the site worked great there. Now after relocating to a new server running W2K8S, everything but mail delivery from the website now works great under IIS 7.

网站最初是在IIS 6下开始的,网站在那里运行良好。现在,在重新定位到运行W2K8S的新服务器之后,除了IIS 7之外,从网站发送邮件的所有内容现在都能正常运行。

Researched briefly on the Web to see if anybody had a good resolution, but no avail... Not even a glimmer of hope on Microsoft's own support site.

在网上进行了简短的研究,看看是否有人有一个好的解决方案,但没有用...甚至没有微软自己的支持网站上的一线希望。

Here are the steps taken so far on the new W2K8S box:

以下是目前在新W2K8S盒子上采取的步骤:

  • Added the feature for SMTP under the Server Manager
  • 在服务器管理器下添加了SMTP功能

  • Enabled SMTP e-mail for the site itself in IIS 7 Manager to deliver e-mail to SMTP server local host, unsuccessful
  • 在IIS 7管理器中为站点本身启用SMTP电子邮件,以将电子邮件传递到SMTP服务器本地主机,但不成功

  • Enabled SMTP e-mail for the root site in IIS 7 Manager (not sure if that needs to be on to enable sites) to deliver e-mail to SMTP server local host, unsuccessful
  • 为IIS 7管理器中的根站点启用SMTP电子邮件(不确定是否需要启用站点)以将电子邮件传递到SMTP服务器本地主机,但不成功

After failing those basic setups, I wanted to be sure I can actually talk from/to the serveron port 25. And I can successfully telnet from/to the server in question to a test e-mail on port 25 get a HELO, etc. So I do not believe it is a firewall config issue.

在失败了这些基本设置之后,我想确保我实际上可以从/向服务器端口25进行通信。并且我可以成功地从/向有问题的服务器远程登录到端口25上的测试电子邮件获取HELO等。所以我不相信这是防火墙配置问题。

The IIS 7 setup test was performed with both anonymous and Windows authentication - no luck either way.

IIS 7安装测试是使用匿名和Windows身份验证执行的 - 无论如何都没有运气。

Manually checked Web Config file and it reflects correct entry for the server to use the localhost.

手动检查Web Config文件,它反映了服务器使用localhost的正确条目。

Read the manual and no luck there either... :-/

阅读手册,没有运气......: - /

8 个解决方案

#1


2  

I faced the same problem.

我遇到了同样的问题。

I came across this link http://www.frontpagewebmaster.com/m-215289/tm.htm

我遇到了这个链接http://www.frontpagewebmaster.com/m-215289/tm.htm

and I was able to solve the issue. Go to the last post of this link.

我能够解决这个问题。转到此链接的最后一篇文章。

In my case I solve problem by giving rights to "NETWORK SERVICE" user to the "Pickup" folder.

在我的情况下,我通过将“NETWORK SERVICE”用户的权限授予“Pickup”文件夹来解决问题。

Hope this might help....

希望这可能有所帮助....

#2


1  

OK, to the post that said "give NETWORK USER the write rights to the pickup folder" it finally works. What I did was:

好的,对于说“给网络用户写入拾取文件夹的权限”的帖子,它最终有效。我做的是:

  1. You need to use a "smart host" unless you are running exchange server. I am using a Gmail account, Gmail allows SMTP forwarding.

    除非您正在运行Exchange服务器,否则您需要使用“智能主机”。我使用的是Gmail帐户,Gmail允许SMTP转发。

  2. You can use Windows authentication for security on the SMTP server and the IIS7 config setting.

    您可以使用Windows身份验证来确保SMTP服务器和IIS7配置设置的安全性。

  3. First step, set the delivery method = "network" in your web page, and get your smart host configured independently of the SMTP server.

    第一步,在网页中设置交付方式=“网络”,并使您的智能主机独立于SMTP服务器进行配置。

    SmtpClient client = new SmtpClient("smtp.gmail.com", 587);
    client.DeliveryMethod = SmtpDeliveryMethod.Network;
    client.UseDefaultCredentials = false; // use your smart host login client.Credentials = new NetworkCredential("xxxxx@gmail.com", "password");
    client.EnableSsl = true;
    

    This will send the email directly and bypass your SMTP server.

    这将直接发送电子邮件并绕过您的SMTP服务器。

  4. Second step, once you have that working, write a sample windows app to use your SMTP server independent of your web page, and get that working.

    第二步,一旦你有了工作,编写一个示例Windows应用程序,使用独立于您的网页的SMTP服务器,并使其工作。

    SmtpClient client = new SmtpClient("your server ip", 25);
    client.DeliveryMethod = SmtpDeliveryMethod.PickupDirectoryFromIis;
    client.EnableSsl = false; // you can't use ssl with a pickup folder
    client.UseDefaultCredentials = true; // use windows credentials
    

    This will bypass your web page and make sure you have your SMTP server configured properly.

    这将绕过您的网页,并确保正确配置您的SMTP服务器。

  5. Finally, get your web page working, by setting the sharing on your pickup folder to allow write access to NETWORK_SERVICE. Transfer the login info from step 3, into your SMTP settings, set authentication to integrated security, and use the code in step 4 for your web page.

    最后,通过在拾取文件夹上设置共享以允许对NETWORK_SERVICE的写访问来使您的网页正常工作。将登录信息从步骤3传输到SMTP设置,将身份验证设置为集成安全性,并使用步骤4中的代码作为您的网页。

#3


1  

I had exactly the same problem as described in this old question. Finally I found a solution to it. In my case the operation system is W2008 R2 with IIS 7.5, but I think this doesn’t matter.

我遇到了与旧问题中描述的完全相同的问题。最后我找到了解决方案。在我的情况下,操作系统是带有IIS 7.5的W2008 R2,但我认为这无关紧要。

The underlying problem is that the SMTP Service in W2008 R2 seems to be a legacy part of the IIS. It is installed with the IIS 6.0 administration tools, side by side to the IIS 7.X Server. This causes two derived problems:

根本问题是W2008 R2中的SMTP服务似乎是IIS的遗留部分。它与IIS 6.0管理工具一起安装,与IIS 7.X Server并排安装。这导致两个派生的问题:

IIS 7.X knows nothing about the SMTP service. If you configure SMTP in ASP.NET to use the PickupDirectoryFromIis this results in an exception. Therefore you can’t use this SMTP configuration:

IIS 7.X对SMTP服务一无所知。如果在ASP.NET中配置SMTP以使用PickupDirectoryFromIis,则会导致异常。因此,您无法使用此SMTP配置:

<smtp deliveryMethod="PickupDirectoryFromIis" />

But it is possible to configure SMTP with SpecifiedPickupDirectory, You can use this configuration:

但是可以使用SpecifiedPickupDirectory配置SMTP,您可以使用此配置:

<smtp deliveryMethod="SpecifiedPickupDirectory">
    <specifiedPickupDirectory pickupDirectoryLocation="C:\inetpub\mailroot\Pickup"  />
</smtp>

If you configure the pickup directory in this way, you may run into a second kind of problem: IIS6 and IIS7.X have different security systems. IIS 7.X introduces integrated security with application pool identities. IIS 6.0 and its SMTP service don’t know about this. Therefore you have to grant write permissions for IIS_IUSRS to the pickup folder. In my configuration the pickup folder is C:\inetpub\mailroot\pickup.

如果以这种方式配置拾取目录,则可能会遇到第二种问题:IIS6和IIS7.X具有不同的安全系统。 IIS 7.X引入了具有应用程序池标识的集成安全性。 IIS 6.0及其SMTP服务不知道这一点。因此,您必须将IIS_IUSRS的写权限授予拾取文件夹。在我的配置中,提取文件夹是C:\ inetpub \ mailroot \ pickup。

#4


1  

I noticed that the event ID 4006 was refering to the domain controller ip instead of the mail server ip. I used the iis 6 admin tool to configure a smarthost pointing to the mail server and voila! the issue was resolved.

我注意到事件ID 4006引用了域控制器ip而不是邮件服务器ip。我使用iis 6管理工具配置指向邮件服务器的智能主机,瞧!问题得到了解决。

#5


0  

I am not sure if this diagnostic tool can provide more insights,

我不确定这个诊断工具能否提供更多见解,

http://www.iis.net/downloads/default.aspx?tabid=34&g=6&i=1308

This tool is for x86.

此工具适用于x86。

#6


0  

Have you checked to see if the SMTP service is accepting mail for relay from localhost? To do this, telnet from the machine in question to the local SMTP server and use SMTP commands to send a test message. The SMTP service is very picky about command formatting so you'll have to be careful when entering commands (i.e. don't use backspace to correct typographical errors).

您是否检查过SMTP服务是否接受来自localhost的中继邮件?为此,请从相关计算机telnet到本地SMTP服务器,并使用SMTP命令发送测试邮件。 SMTP服务非常挑剔命令格式,因此在输入命令时必须小心(即不要使用退格键来纠正打字错误)。

#7


0  

Is this, by chance, an old "classic" ASP app relying on CDONTS to send mail?

这是偶然的,依旧CDONTS发送邮件的旧“经典”ASP应用程序吗?

If so, perhaps one of these links would be helpful?

如果是这样,也许其中一个链接会有所帮助?

Edited: I had replied before noticing the note on the original post. Disregard...

编辑:我在注意到原帖上的注释之前回复了。漠视...

#8


0  

I came across this post when researching getting SMTP running on my ASP.Net app we're migrating from IIS6 to IIS7. What I found was we didn't have to set up the SMTP SERVER at all - simply setting up SMTP Email was enough - with the additional benefit of NOT having the security concerns of SMTP relaying thru the web server!

我在研究在我的ASP.Net应用程序上运行SMTP时遇到了这个帖子,我们正在从IIS6迁移到IIS7。我发现我们根本没有设置SMTP服务器 - 只需设置SMTP电子邮件就足够了 - 还有一个好处就是没有SMTP通过Web服务器中继的安全问题!

so if you don't need your web server to actually do the SMTP routing, you don't have to set up the server at all in IIS7.

因此,如果您不需要Web服务器实际执行SMTP路由,则不必在IIS7中设置服务器。

#1


2  

I faced the same problem.

我遇到了同样的问题。

I came across this link http://www.frontpagewebmaster.com/m-215289/tm.htm

我遇到了这个链接http://www.frontpagewebmaster.com/m-215289/tm.htm

and I was able to solve the issue. Go to the last post of this link.

我能够解决这个问题。转到此链接的最后一篇文章。

In my case I solve problem by giving rights to "NETWORK SERVICE" user to the "Pickup" folder.

在我的情况下,我通过将“NETWORK SERVICE”用户的权限授予“Pickup”文件夹来解决问题。

Hope this might help....

希望这可能有所帮助....

#2


1  

OK, to the post that said "give NETWORK USER the write rights to the pickup folder" it finally works. What I did was:

好的,对于说“给网络用户写入拾取文件夹的权限”的帖子,它最终有效。我做的是:

  1. You need to use a "smart host" unless you are running exchange server. I am using a Gmail account, Gmail allows SMTP forwarding.

    除非您正在运行Exchange服务器,否则您需要使用“智能主机”。我使用的是Gmail帐户,Gmail允许SMTP转发。

  2. You can use Windows authentication for security on the SMTP server and the IIS7 config setting.

    您可以使用Windows身份验证来确保SMTP服务器和IIS7配置设置的安全性。

  3. First step, set the delivery method = "network" in your web page, and get your smart host configured independently of the SMTP server.

    第一步,在网页中设置交付方式=“网络”,并使您的智能主机独立于SMTP服务器进行配置。

    SmtpClient client = new SmtpClient("smtp.gmail.com", 587);
    client.DeliveryMethod = SmtpDeliveryMethod.Network;
    client.UseDefaultCredentials = false; // use your smart host login client.Credentials = new NetworkCredential("xxxxx@gmail.com", "password");
    client.EnableSsl = true;
    

    This will send the email directly and bypass your SMTP server.

    这将直接发送电子邮件并绕过您的SMTP服务器。

  4. Second step, once you have that working, write a sample windows app to use your SMTP server independent of your web page, and get that working.

    第二步,一旦你有了工作,编写一个示例Windows应用程序,使用独立于您的网页的SMTP服务器,并使其工作。

    SmtpClient client = new SmtpClient("your server ip", 25);
    client.DeliveryMethod = SmtpDeliveryMethod.PickupDirectoryFromIis;
    client.EnableSsl = false; // you can't use ssl with a pickup folder
    client.UseDefaultCredentials = true; // use windows credentials
    

    This will bypass your web page and make sure you have your SMTP server configured properly.

    这将绕过您的网页,并确保正确配置您的SMTP服务器。

  5. Finally, get your web page working, by setting the sharing on your pickup folder to allow write access to NETWORK_SERVICE. Transfer the login info from step 3, into your SMTP settings, set authentication to integrated security, and use the code in step 4 for your web page.

    最后,通过在拾取文件夹上设置共享以允许对NETWORK_SERVICE的写访问来使您的网页正常工作。将登录信息从步骤3传输到SMTP设置,将身份验证设置为集成安全性,并使用步骤4中的代码作为您的网页。

#3


1  

I had exactly the same problem as described in this old question. Finally I found a solution to it. In my case the operation system is W2008 R2 with IIS 7.5, but I think this doesn’t matter.

我遇到了与旧问题中描述的完全相同的问题。最后我找到了解决方案。在我的情况下,操作系统是带有IIS 7.5的W2008 R2,但我认为这无关紧要。

The underlying problem is that the SMTP Service in W2008 R2 seems to be a legacy part of the IIS. It is installed with the IIS 6.0 administration tools, side by side to the IIS 7.X Server. This causes two derived problems:

根本问题是W2008 R2中的SMTP服务似乎是IIS的遗留部分。它与IIS 6.0管理工具一起安装,与IIS 7.X Server并排安装。这导致两个派生的问题:

IIS 7.X knows nothing about the SMTP service. If you configure SMTP in ASP.NET to use the PickupDirectoryFromIis this results in an exception. Therefore you can’t use this SMTP configuration:

IIS 7.X对SMTP服务一无所知。如果在ASP.NET中配置SMTP以使用PickupDirectoryFromIis,则会导致异常。因此,您无法使用此SMTP配置:

<smtp deliveryMethod="PickupDirectoryFromIis" />

But it is possible to configure SMTP with SpecifiedPickupDirectory, You can use this configuration:

但是可以使用SpecifiedPickupDirectory配置SMTP,您可以使用此配置:

<smtp deliveryMethod="SpecifiedPickupDirectory">
    <specifiedPickupDirectory pickupDirectoryLocation="C:\inetpub\mailroot\Pickup"  />
</smtp>

If you configure the pickup directory in this way, you may run into a second kind of problem: IIS6 and IIS7.X have different security systems. IIS 7.X introduces integrated security with application pool identities. IIS 6.0 and its SMTP service don’t know about this. Therefore you have to grant write permissions for IIS_IUSRS to the pickup folder. In my configuration the pickup folder is C:\inetpub\mailroot\pickup.

如果以这种方式配置拾取目录,则可能会遇到第二种问题:IIS6和IIS7.X具有不同的安全系统。 IIS 7.X引入了具有应用程序池标识的集成安全性。 IIS 6.0及其SMTP服务不知道这一点。因此,您必须将IIS_IUSRS的写权限授予拾取文件夹。在我的配置中,提取文件夹是C:\ inetpub \ mailroot \ pickup。

#4


1  

I noticed that the event ID 4006 was refering to the domain controller ip instead of the mail server ip. I used the iis 6 admin tool to configure a smarthost pointing to the mail server and voila! the issue was resolved.

我注意到事件ID 4006引用了域控制器ip而不是邮件服务器ip。我使用iis 6管理工具配置指向邮件服务器的智能主机,瞧!问题得到了解决。

#5


0  

I am not sure if this diagnostic tool can provide more insights,

我不确定这个诊断工具能否提供更多见解,

http://www.iis.net/downloads/default.aspx?tabid=34&g=6&i=1308

This tool is for x86.

此工具适用于x86。

#6


0  

Have you checked to see if the SMTP service is accepting mail for relay from localhost? To do this, telnet from the machine in question to the local SMTP server and use SMTP commands to send a test message. The SMTP service is very picky about command formatting so you'll have to be careful when entering commands (i.e. don't use backspace to correct typographical errors).

您是否检查过SMTP服务是否接受来自localhost的中继邮件?为此,请从相关计算机telnet到本地SMTP服务器,并使用SMTP命令发送测试邮件。 SMTP服务非常挑剔命令格式,因此在输入命令时必须小心(即不要使用退格键来纠正打字错误)。

#7


0  

Is this, by chance, an old "classic" ASP app relying on CDONTS to send mail?

这是偶然的,依旧CDONTS发送邮件的旧“经典”ASP应用程序吗?

If so, perhaps one of these links would be helpful?

如果是这样,也许其中一个链接会有所帮助?

Edited: I had replied before noticing the note on the original post. Disregard...

编辑:我在注意到原帖上的注释之前回复了。漠视...

#8


0  

I came across this post when researching getting SMTP running on my ASP.Net app we're migrating from IIS6 to IIS7. What I found was we didn't have to set up the SMTP SERVER at all - simply setting up SMTP Email was enough - with the additional benefit of NOT having the security concerns of SMTP relaying thru the web server!

我在研究在我的ASP.Net应用程序上运行SMTP时遇到了这个帖子,我们正在从IIS6迁移到IIS7。我发现我们根本没有设置SMTP服务器 - 只需设置SMTP电子邮件就足够了 - 还有一个好处就是没有SMTP通过Web服务器中继的安全问题!

so if you don't need your web server to actually do the SMTP routing, you don't have to set up the server at all in IIS7.

因此,如果您不需要Web服务器实际执行SMTP路由,则不必在IIS7中设置服务器。