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

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

报告相同问题?

悬赏问题

  • ¥20 wireshark抓不到vlan
  • ¥20 关于#stm32#的问题:需要指导自动酸碱滴定仪的原理图程序代码及仿真
  • ¥20 设计一款异域新娘的视频相亲软件需要哪些技术支持
  • ¥15 stata安慰剂检验作图但是真实值不出现在图上
  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来