2016-08-24 31 views
0

PHP寄回假是我的代码PHP邮件不工作,当我运行邮件功能</p> <p>这里返回false

$to = '[email protected]'; 
$subject = 'Login'; 
$message = 'Thanks for Login ! Your account has been logged on website.'; 
$headers = 'From:[email protected]' . "\r\n"; 
var_dump(mail($to, $subject, $message, $headers)); 

当我打开邮件日志,没有发现错误,当我考到发使用此命令的邮件通过Ubuntu的终端

echo "Test mail from postfix" | mail -s "Test Postfix" [email protected] 

其发送给我发邮件正确

也是我配置的php.ini

sendmail_path = /usr/sbin/sendmail -t -i -f [email protected] 
+0

你正试图从本地主机或服务器直播发送邮件? – Karthi

+0

活服务器它是本地工作,并返回true –

+0

检查您的标题 – Karthi

回答

0

先试试这个:使用此代码进行连接

<html> 

    <head> 
     <title>Sending HTML email using PHP</title> 
    </head> 

    <body> 

     <?php 
     $to = "[email protected]"; 
     $subject = "This is subject"; 

     $message = "<b>This is HTML message.</b>"; 
     $message .= "<h1>This is headline.</h1>"; 

     $header = "From:[email protected] \r\n"; 
     $header .= "Cc:[email protected] \r\n"; 
     $header .= "MIME-Version: 1.0\r\n"; 
     $header .= "Content-type: text/html\r\n"; 

     $retval = mail ($to,$subject,$message,$header); 

     if($retval == true) { 
      echo "Message sent successfully..."; 
     }else { 
      echo "Message could not be sent..."; 
     } 
     ?> 

    </body> 
</html> 
+0

它返回消息无法发送... –

+0

其工作我检查您的配置 – Karthi

+0

我已经改变了php.ini sendmail_path =/usr/sbin/sendmail -t -i -f [email protected] –