似乎没有人真正找到明确的答案,所以我做了一些挖掘并找出原因。
在system/libraries/Email.php中,先看第1552行:
if ( ! mail($this->_recipients, $this->_subject, $this->_finalbody, $this->_header_str, "-f ".$this->clean_email($this->_headers['From'])))
它似乎把所有的东西都像桃子一样发送出去。我也有完全相同的症状。为了看看我是不是疯了,我在前面插入了...
mail($this->_recipients, $this->_subject, $this->_finalbody)
所以我基本上删除了所有标题并让 PHP 放入默认值。答对了!没有 CI 的标头,它可以工作。对于 CI 标头,它不会。那是什么?
进一步挖掘,我查看了 html 的初始化和使用位置。事实证明它直到 1046 年左右才真正做任何事情,在那里它构建了消息正文。
从第 1048 行开始:
if ($this->send_multipart === FALSE)
{
$hdr .= "Content-Type: text/html; charset=" . $this->charset . $this->newline;
$hdr .= "Content-Transfer-Encoding: quoted-printable";
}
else
{
$hdr .= "Content-Type: multipart/alternative; boundary=\"" . $this->_alt_boundary . "\"" . $this->newline . $this->newline;
$body .= $this->_get_mime_message() . $this->newline . $this->newline;
$body .= "--" . $this->_alt_boundary . $this->newline;
$body .= "Content-Type: text/plain; charset=" . $this->charset . $this->newline;
$body .= "Content-Transfer-Encoding: " . $this->_get_encoding() . $this->newline . $this->newline;
$body .= $this->_get_alt_message() . $this->newline . $this->newline . "--" . $this->_alt_boundary . $this->newline;
$body .= "Content-Type: text/html; charset=" . $this->charset . $this->newline;
$body .= "Content-Transfer-Encoding: quoted-printable" . $this->newline . $this->newline;
}
在 TRUE 和 FALSE 之间翻转 send_multipart 将使邮件类工作或不工作。
查看Code Ignitor's email class docs 没有发现任何问题。转到第 52 行:
var $send_multipart = TRUE; // TRUE/FALSE - Yahoo does not like multipart alternative, so this is an override. Set to FALSE for Yahoo.
所以你有它。 CI如何处理多部分消息可能有错误?隐藏的配置偏好
$config['send_multipart'] = FALSE;
在 email.php 中似乎可以解决问题。