dsfs64664 2012-09-18 18:27
浏览 35
已采纳

使用sendmail在计划任务中从php脚本发送邮件

I am sending mail using sendmail package in my application the mail sending function is simple :

mail($to,$subject,$mailmessage);

My application is installed on Windows Server 2008 ![enter image description here][1] I have scheduled a task using task scheduler to run the script every 5 minutes

All the script runs but mail is not working the error I get on the cmd display is :

PHP Warning: mail(): Failed to connect to mailserver at "localhost" port 25, ve rify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\wamp\ www\RCold\mailingcron.php on line 3 PHP Stack trace: PHP 1. {main}() C:\wamp\www\RCold\mailingcron.php:0 PHP 2. mail() C:\wamp\www\RCold\mailingcron.php:3

Warning: mail(): Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\wamp\www\R Cold\mailingcron.php on line 3

Call Stack: 0.0008 227816 1. {main}() C:\wamp\www\RCold\mailingcron.php:0 0.0008 228800 2. mail() C:\wamp\www\RCold\mailingcron.php:3

If I run the same script on a browser, the mail function works properly.

How can I run the mail function from command line

  • 写回答

1条回答 默认 最新

  • doutuo4285 2012-09-18 18:39
    关注

    PHP CLI and mod_php/Apache use different php.ini files in WAMP. Make sure your settings are the same in both, or use the ini_set() function as indicated in your error message.

    Here are some common locations for each:

    C:\wamp\bin\php\php5.3.X\php.ini CLI

    C:\wamp\bin\apache\Apache2.X\bin\php.ini APACHE

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?