Php 电子邮件发送代码不工作

Php 电子邮件发送代码不工作,php,Php,我正在尝试用我的php程序发送电子邮件 这是我的密码 $to = "sunilchhimpa92@gmail.com"; $subject = "This is subject"; $message = "This is simple text message."; $header = "sunilchhimpa92@yahoo.com \r\n"; $mail_send = mail($to,$subject,$message,$header); echo $to. $s

我正在尝试用我的php程序发送电子邮件

这是我的密码

  $to = "sunilchhimpa92@gmail.com";
  $subject = "This is subject";
  $message = "This is simple text message.";
  $header = "sunilchhimpa92@yahoo.com \r\n";
 $mail_send = mail($to,$subject,$message,$header);
  echo $to. $subject.$message.$header;
  var_dump($mail_send);
  if( $mail_send == true )  
  {
    echo "Message sent successfully...";
  }
   else
   {
     echo "Message could not be sent...";
   }
这里var\u dump$mail\u send返回false

无法发送回显消息

我的代码有什么问题

是否需要发件人邮件的密码


我该怎么做呢?

您可以在服务器的工作状态中检查此服务器

$admin_to   = 'bhavesh930@gmail.com';
$a_subject  = 'Subject';
$a_from     = 'someone@gmail.com';
$fromcc     = 'someone@gmail.com';      //for multiple user if required than only          

$a_headers = "MIME-Version: 1.0\r\n";
$a_headers .= "Content-type: text/html; charset=utf-8\r\n";
$a_headers .= "From:".$a_from."\r\n";

$a_headers .= "Bcc: ".$fromcc."\r\n";

$a_message= "<html>
   <body>
        <table width='100%' border='0' cellspacing='0' cellpadding='0'>

    <tr>
        <td>Message</td>
    </tr>

        </table>
    </body>
   </html>";

 $sendmail =  @mail($a_to,$a_subject,$a_message,$a_headers);

这不是有效的标题。$headers='来自:webmaster@example.com' . \r\n.“答复:webmaster@example.com' . \r\n.“X-Mailer:PHP/”。phpversion;got it mail php Manual如果您是从本地服务器使用它,则在配置SMTPi之前,您无法从本地主机发送电子邮件。我也尝试了$headers=from:sunilchhimpa92@yahoo.com\r\n适用于:sunilchhimpa92@yahoo.com;是的,我在本地服务器上做。如何配置SMTP