我尝试使用我的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_dump($ mail_send)返回false。
和echo消息无法发送...
我的代码有什么问题
是否需要发件人邮件的密码?
我该怎么做?
答案 0 :(得分:0)
您可以在服务器中检查它的工作情况。
$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);