我目前在工作中使用一个自定义的库。直到最近,该库一直运行完美。现在它似乎从今天开始返回 false。
这个库本质上是围绕函数 mail 的包装器。它构建了“边界”部分和其他所有内容。
由于该类非常大,我不会在这里贴出代码...但我想知道,在理论上,为什么 mail 会返回 false 呢?
- SMTP 在 PHP.ini 中已设置
- 发送者在头部中设置
- 发送者的格式为:
sender<sender@email.com
> - 一切都正确发送(正文+头部+主题)
- 假设 mail() 在网站上能够正常工作,但在此特定页面上却不能。我知道这肯定是由我引起的,但如果能有一个起点开始寻找就好了。
- 哦,对了,这个库是没有文档的。
[编辑] 刚刚发现一个更小的函数,但仍然无效,我将把它打印出来:
function send_html($from, $email, $subject = "AUCUN", $message, $cc = "", $bcc ="", $priotity = "3") {
$headers = "";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
if (strpos($from, "ourwebsite.com") != false || strpos($from, "rencontresportive.com") != "") {
$headers .= "From: Ourwebsite.com <" . $from . ">\r\n";
} else {
$headers .= "From: " . $from . " <" . $from . ">\r\n";
}
$headers .= "X-Sender: <" . $from . ">\r\n";
$headers .= "X-Priority: " . $priotity . "\r\n";
$headers .= "X-Mailer: PHP\r\n";
$headers .= "Return-Path: <admin@ourwebsite.com>\r\n";
if ($cc != "") {
$headers .= "cc:" . $cc . "\r\n";
}
if ($bcc != "") {
$headers .= "bcc:" . $bcc . "\r\n";
}
if (mail($email, $subject, $message, $headers)) {
return true;
} else {
return false;
}
}
我使用以下方式调用它:
send_html(contact@ourwebsite.com, me@me.com, utf8_decode("the subject"), "<h1>test</h1>");