Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

PHP 5.3.13 and as noted IIS 7.5. PHP mail() was working fine until I did 3 things (at the same time). (a) added memory to the server taking it from 4gb to 5gb; (b) ran Windows Update and applied all available updates; (c) removed SQL server installation.

Windows 2008 R2 SMTP server still works fine. I know this because I can drop a file in the pickup folder and the mail is delivered.

This PHP test script:

<?php 
$to='my_name@another_domain.com'; 
$subject='Test email using PHP'; 
$message='This is a test email message'. "\r\n"; 
$headers='From:support@mydomain.com' . "\r\n" 
       . 'Reply-To:support@mydomain.com' . "\r\n" 
       . 'X-Mailer: PHP/' . phpversion(); 

mail($to, $subject, $message, $headers, '-fsupport@mydomain.com'); 
?>

creates this entry in the PHP log file:

 mail() on [C:\www\pgs.com\store\admin\test_php_mail.php:1]: To: my_name@another_domain.com -- Headers: From:support@mydomain.com  Reply-To:support@mydomain.com  X-Mailer: PHP/5.3.13

PHP's mail.log.

When using PHP now, I never see a file dropping on the IIS pickup folder. And on other thing, when using previouly working features on the site (such as password recovery), there is no entry made in the mail.log. (The mail log has just been setup to help solve this problem.)

How do I fix this? Or at least how do I diagnose the problem? Thanks.

share|improve this question
    
What does ini_get('SMTP') return? –  Mathias R. Jessen Oct 19 '13 at 18:43
    
@MathiasR.Jessen returns localhost. –  Karl Oct 20 '13 at 14:14

3 Answers 3

Providing some detail of how the mail is configured in PHP would help.

I avoid MSWindows as much as possible on servers - but I was unaware that PHP will create a mail.log file (it's very unusual that PHP would interact with files in such a way at all given it's architecture) and there's nothing in the code you've published which would write such a file. Are you sure this is not created by your MTA?

Have you tried sending an email by entering SMTP commands directly into a telnet session? Using a different email client on the system?

share|improve this answer
    
Comment in PHP.ini v5.3.x ; The path to a log file that will log all mail() calls. Log entries include ; the full path of the script, line number, To address and headers. –  Karl Oct 20 '13 at 14:07
    
Yes, I can send email using telnet. I doubt if it's an SMTP issue, otherwise dropping a mail file on the pickup folder would not result in it being sent, right? As to how PHP is configured, these are the only setting I know about for send(): [mail function] ; For Win32 only.; http://php.net/smtp SMTP = localhost ; http://php.net/smtp-port smtp_port = 25 located in PHP.ini. Are there other settings? –  Karl Oct 20 '13 at 14:51

Under the virtual SMTP server's properties - on the "Access" tab, I granted permission for the public IP address of the server to relay email. Stop and then started the SMTP server, and all is well. Note that I had mentioned that email from the PHP application never landed in the pickup folder - it still doesn't. It does go to the queue folder however. (The SMTP server properties can be accessed using the IIS 6.0 Manager.)

share|improve this answer

I doubt it is your problem but, there is also a "sendmail_from" setting that is for Win32 only. Should be directly below your "smtp_port" setting in php.ini.

Perhaps the removal of SQL Server caused the problem. Do you have the SMTP Server feature installed on the IIS box? If not, I think you'll need to either install it, or you'll need to point to a real SMTP Server in php.ini rather than SMTP=localhost.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.