简体   繁体   English

php mail()函数和IIS

[英]php mail() function and IIS

I have coded a site with PHP. 我已经用PHP编写了一个网站。 Our client deployed the site to IIS. 我们的客户将站点部署到IIS。 They installed PHP 5.2 but mail() function doesnt work on their server. 他们安装了PHP 5.2,但mail()函数在其服务器上不起作用。

They added this config file in the www folder: 他们在www文件夹中添加了此配置文件:

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: mail()函数生成以下错误:

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. 我知道必须有一个简单的解决方案,即编辑php.ini文件。 But the person in charge has said that they couldnt edit php.ini and we have to code contact page with asp. 但是负责人说,他们无法编辑php.ini ,我们必须使用ASP对联系页面进行编码。

Is there any way to send mail using php in this case? 在这种情况下,有什么方法可以使用php发送邮件吗?

There was a long outstanding bug in the mail() function in PHP 5.2 on Windows: Windows上的PHP 5.2中的mail()函数中存在一个长期存在的错误:

Bug #28038 Sent incorrect RCPT TO commands to SMTP server 错误#28038将不正确的RCPT TO命令发送到SMTP服务器

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. mail()函数错误地分析了From:头,并且行为表现最佳的RFC兼容邮件服务器将拒绝它为无效地址。

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). 现在,此问题已在PHP 5.2.11+中修复(我已经在PHP 5.2.14,PHP 5.2.17和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. 因此,我将找出您的应用程序在其下运行的PHP 5.2.x的确切版本,并查看它是否受此错误影响。

However, I'd recommend using SwiftMailer instead. 但是,我建议改用SwiftMailer 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. 您可以对诸如配置外发邮件服务器,身份验证之类的东西进行更多控制,并且它不依赖于使用内置的mail()函数。 We have several customers using this on our shared hosting platform and they're very happy with it. 我们有几个客户在我们的共享托管平台上使用它,他们对此感到非常满意。

you can try and set options with 您可以尝试并设置选项

ini_set() ini_set()

function 功能

ini_set reference ini_set参考

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM