这些是我的标题:
$defaultHeaders = 'MIME-Version: 1.0' . "\r\n";
$defaultHeaders .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
$defaultHeaders .= 'From: Kyote Productions <no-reply@' . $_SERVER['SERVER_NAME'] . '>' . "\r\n";
$this->headers = (!empty($headers)) ? $headers : $defaultHeaders;
这些是我的主题,信息和收件人:
$this->subject = $subject;
$this->message = $message;
$this->to = $recipient;
我发送的邮件是这样的:
return mail($this->to, $this->subject, $this->message, $this->headers);
当我将方法写入var_dump()
所有这些结果时,它们看起来像这样:
array(4) {
[0]=>
string(39) "x@outlook.com,z@gmail.com,"
[1]=>
string(18) "PHP Mailer by Kyle"
[2]=>
string(187) "<html><head><title>PHP Mailer by Kyle</title></head><body><img style="width: 100%; height: 200px;" src="http://wallpapercave.com/wp/Qom1Iwe.jpg"><br /><br />Test email baby!</body></html>"
[3]=>
string(112) "MIME-Version: 1.0
Content-type: text/html; charset=UTF-8
From: Kyote Productions <no-reply@kyoteprod.x10.mx>
"
}
1
错误报告已启用,但我没有收到任何错误,并且在运行此错误时返回1:
echo (int)$obj->sendMail();
答案 0 :(得分:0)
您是否安装了邮件服务器?
根据php.net mail page:“重要的是要注意,仅仅因为邮件已被接受传递,这并不意味着邮件实际上会到达预定目的地。”< / p>
我还要指出this question about sending mail with php和this question about sending mail on linux。
您也可以尝试使用PHPMailer class而不是自己动手;它非常方便。