邮件返回错误
2022-08-30 21:58:46
我目前正在工作中使用定制的库。直到刚刚兴起,图书馆才完美地工作。它显然从今天开始返回错误。
库本身基本上是函数邮件的包装器。它建立了“边界”部分和一切。
由于课程足够大,我不会在这里发布它...但是我想知道,从理论上讲,为什么邮件会返回假的是什么原因?
- 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>");