du521521521 2018-06-28 05:42
浏览 18
已采纳

PHP邮件功能在服务器上不起作用[重复]

This question already has an answer here:

I recently shifted my servers and found that default PHP mail function is not working which was working in the previous server. I tested it by writing simple mail function

$mailto="me@domain.com";  //Enter recipient email address here

$subject = "Test Email";

$from="you@domain.com";          //Your valid email address here

$message_body = "This is a test email from Webmaster.";

$mail =   mail($mailto,$subject,$message_body,"From:".$from);
var_dump($mail);
if($mail) {
    echo "Your email has been sent successfully";
} else {
    echo "not sent";
}

Above code return me false value. I googled it. checked my PHP.ini. It is also set as the solution mentioned in the google links.

; For Win32 only. 

; http://php.net/sendmail-from

;sendmail_from =me@example.com

; For Unix only.  You may supply arguments as well
(default: "sendmail -t -i").  
; http://php.net/sendmail-path

sendmail_path = "/usr/sbin/sendmail -t -i"

I don't what I am missing.

</div>
  • 写回答

2条回答 默认 最新

  • dongyan2469 2018-06-28 06:37
    关注

    It returns FALSE, it means there is a problem with your mail configuration. You would need to check the mail log to see if you are getting any errors. The kicker is that php may be handing off the mail, your server may be sending off the mail, and it may get spam filtered along the way.

    <?php 
        mail('nobody@example.com', 'the subject', 'the message', null, '-fwebmaster@example.com'); 
    ?> 
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 乘性高斯噪声在深度学习网络中的应用
  • ¥15 运筹学排序问题中的在线排序
  • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
  • ¥30 求一段fortran代码用IVF编译运行的结果
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥30 python代码,帮调试,帮帮忙吧