0

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?

4
  • 1
    Can you describe what about mail isn't actually working? How about the code you're using to call it. Commented Apr 10, 2011 at 8:47
  • server eroor - 500 - Internal server error. There is a problem with the resource you are looking for, and it cannot be displayed. Commented Apr 10, 2011 at 11:10
  • please check the error log for the site. Check the log_errors and error_log directives in php.ini for more information on where to find the actual log file. If log_errors is "Off" or error_log is blank, correct that problem and try again. Also, again, please post the PHP code you are using that is failing. Commented Apr 10, 2011 at 13:53
  • What version of IIS? Do you have an SMTP server set up already? Commented Apr 11, 2011 at 0:05

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

Comments

0

you can try and set options with

ini_set()

function

ini_set reference

1 Comment

with : ini_set("SMTP","localhost"); ini_set("smtp_port","25"); ini_set("sendmail_from","string"); but result is the same

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.