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

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

报告相同问题?

悬赏问题

  • ¥15 PADS Logic 原理图
  • ¥15 PADS Logic 图标
  • ¥15 电脑和power bi环境都是英文如何将日期层次结构转换成英文
  • ¥20 气象站点数据求取中~
  • ¥15 如何获取APP内弹出的网址链接
  • ¥15 wifi 图标不见了 不知道怎么办 上不了网 变成小地球了
  • ¥50 STM32单片机传感器读取错误
  • ¥15 (关键词-阻抗匹配,HFSS,RFID标签天线)
  • ¥15 机器人轨迹规划相关问题
  • ¥15 word样式右侧翻页键消失