php mail()函数和IIS [英] php mail() function and IIS

查看:242
本文介绍了php mail()函数和IIS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用PHP编写了一个网站。我们的客户将该站点部署到IIS。他们安装了PHP 5.2,但是 mail()函数在他们的服务器上无法正常工作。



他们在这里添加了这个配置文件www文件夹:



web.config:

 <结构> 
< system.webServer>
< handlers>
< remove name =PHP- fastcgi/>
< add name =PHP - FastCGIpath =* .phpverb =*
modules =FastCgiModule
scriptProcessor =C:\Php \ php -cgi.exeresourceType =未指定/>
< / handlers>
< defaultDocument>
< files>
< add value =default.php/>
< add value =index.php/>
< / files>
< / defaultDocument>
< /system.webServer>
< / configuration>

mail()功能:

 服务器错误 -  500  - 内部服务器错误。 
您要查找的资源存在问题,无法显示。

我知道必须有一个简单的解决方案,编辑 php。 ini 文件。但负责人说他们无法编辑 php.ini ,我们必须用asp编写联系页面。



<在这种情况下,有没有办法用PHP发送邮件?

解决方案

<$> <$> <$> c $ c> mail() Windows上的PHP 5.2中的函数:


错误#28038向SMTP服务器发送了错误的RCPT TO命令


mail()函数正在正确解析 From:标题并且大多数正常运行的符合RFC的邮件服务器都会将其拒绝为无效地址。



现在已经在PHP 5.2.11+中修复了这个问题(我已经用PHP 5.2进行了测试。 14,PHP 5.2.17和PHP 5.3.6)。所以我会找到你的应用程序运行的PHP 5.2.x的确切版本,看看它是否受到这个bug的影响。



但是,我建议改用 SwiftMailer 。您可以更好地控制配置外发邮件服务器,身份验证等内容,并且不依赖于使用内置的 mail()功能。我们有几个客户在我们的共享托管平台上使用它,他们对此非常满意。


I have coded a site with PHP. Our client deployed the site to IIS. They installed PHP 5.2 but mail() function doesnt work on their server.

They added this config file in the www folder:

web.config:

<configuration>
    <system.webServer>
        <handlers>
            <remove name="PHP- fastcgi" />
            <add name="PHP - FastCGI" path="*.php" verb="*" 
                 modules="FastCgiModule" 
                 scriptProcessor="C:\Php\php-cgi.exe" resourceType="Unspecified" />
        </handlers>
        <defaultDocument>
            <files>
                <add value="default.php" />
                <add value="index.php" />
            </files>
        </defaultDocument>
    </system.webServer>
</configuration>

The following error is generated by the mail() function:

server error - 500 - Internal server error.
There is a problem with the resource you are looking for, and it cannot be displayed.

I know there must be a simple solution with an edit of the php.ini file. But the person in charge has said that they couldnt edit php.ini and we have to code contact page with asp.

Is there any way to send mail using php in this case?

解决方案

There was a long outstanding bug in the mail() function in PHP 5.2 on Windows:

Bug #28038 Sent incorrect RCPT TO commands to SMTP server

The From: header was being parsed incorrectly by the mail() function and most properly behaved RFC compliant mail servers will reject it as an invalid address.

This is now fixed in PHP 5.2.11+ (I have tested this with PHP 5.2.14, PHP 5.2.17 and PHP 5.3.6). So I'd find out the exact version of PHP 5.2.x your application is running under and see if it's affected by this bug.

However, I'd recommend using SwiftMailer instead. You get a lot more control over stuff like configuring the outgoing mail server, authentication and so on and it doesn't rely on using the built-in mail() function. We have several customers using this on our shared hosting platform and they're very happy with it.

这篇关于php mail()函数和IIS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆