dongzhi6927 2016-07-16 07:47
浏览 18

PHP邮件()不工作,代码输出成功但我没有收到任何电子邮件[重复]

This question already has an answer here:

I use mail() to send emails but the output says it is success but i do not received any emails. can someone help me please in using mail()?

function send_mail() {

    $message = 'Please reset your passwrod etc.';

    if (mail('ruedastefano@gmail.com', 'password reset', $message, 'from: bjmpncr@thefourpobu.com')) {

        echo 'success';
    } else {
        echo 'failed';
    }
}  
</div>
  • 写回答

1条回答 默认 最新

  • doukuanyong1939 2016-07-16 10:50
    关注

    Its because your mail config not set correctly.

    Check

    1. Environment(if local check this / if live-host most of time it will config automaticaly)
    2. User Authentication(Username / password)

    Sample code

    $to = "abdulla@stackoverflow.com";
    
    $subject = 'Place Order From ';
    $message = 'My message goes here';
    
    $headers = "MIME-Version: 1.0
    ";
    $headers .= "Content-Type: text/html; charset=ISO-8859-1
    ";
    $headers .= "From: ibjmpncr@thefourpobu.com";
    
    mail($to, $subject, $message, $headers);
    

    Requirements for php mail() function

    php.net

    For the Mail functions to be available, PHP must have access to the sendmail binary on your system during compile time. If you use another mail program, such as qmail or postfix, be sure to use the appropriate sendmail wrappers that come with them. PHP will first look for sendmail in your PATH, and then in the following: /usr/bin:/usr/sbin:/usr/etc:/etc:/usr/ucblib:/usr/lib. It's highly recommended to have sendmail available from your PATH. Also, the user that compiled PHP must have permission to access the sendmail binary.

    w3Schools

    For the mail functions to be available, PHP requires an installed and working email system. The program to be used is defined by the configuration settings in the php.ini file.

    评论

报告相同问题?

悬赏问题

  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效