想知道是否有任何函数/类等能够帮助解决电子邮件中990个字符限制的问题,因为我的HTML受到了影响。
问题如下(来源:Source):
请注意,邮件服务器对电子邮件中每行的字符数有990个限制。如果发送的电子邮件包含超过990个字符的行,则这些行将被附加的换行符分成多个部分,这可能会导致电子邮件消息出现损坏,特别是对于HTML内容。为了防止这种情况发生,在电子邮件消息中适当的位置添加自己的换行符以确保没有行超过990个字符。
有其他人也遇到这个问题吗?你们是怎么解决的?
听起来我需要找一个好的地方来分割我的HTML并手动添加换行符,唉...
更新:
这是有很多行的制表数据。那么我需要在哪里添加 \n 或
更新 #2:添加MIME类型代码。
以下是我如何调用这些函数的方法:
最初的调用方式:
问题如下(来源:Source):
请注意,邮件服务器对电子邮件中每行的字符数有990个限制。如果发送的电子邮件包含超过990个字符的行,则这些行将被附加的换行符分成多个部分,这可能会导致电子邮件消息出现损坏,特别是对于HTML内容。为了防止这种情况发生,在电子邮件消息中适当的位置添加自己的换行符以确保没有行超过990个字符。
有其他人也遇到这个问题吗?你们是怎么解决的?
听起来我需要找一个好的地方来分割我的HTML并手动添加换行符,唉...
更新:
这是有很多行的制表数据。那么我需要在哪里添加 \n 或
<br />
?更新 #2:添加MIME类型代码。
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=iso-8859-1\r\n";
$headers .= "Content-Transfer-Encoding: quoted-printable\r\n"; // added this, but still no results
$headers .= "From: from@email.com\r\n";
以下是我如何调用这些函数的方法:
最初的调用方式:
return $html;
我尝试过的方法:
return imap_8bit($html); // not working, nothing is captured in the error log
AND
return imap_binary($html); // not working, nothing is captured in the error log
更新 #3(添加邮件功能)
try {
mail(
'to@email.com',
'Subject of Email',
$html,
$headers
);
} catch (Exception $e) {
echo ("ERROR: Email NOT sent, Exception: ".$e->getMessage());
}
示例HTML(这是HTML电子邮件的消息)(这也是XMLRPC服务的一部分类)
private function getHTML() {
$html = '<html><head><title>Title</title></head><body>';
$html .= '<table>';
$html .= '<tr><td>many many rows like this</td></tr>';
$html .= '<tr><td>many many rows like this</td></tr>';
$html .= '<tr><td>many many rows like this</td></tr>';
$html .= '<tr><td>many many rows like this</td></tr>';
$html .= '<tr><td>many many rows like this</td></tr>';
$html .= '</table>';
$html .= '</body>';
$html .= '</html>';
return $html;
//return imap_8bit($html); // not working, nothing is captured in the error log
//return imap_binary($html); // not working, nothing is captured in the error log
// Both of these return the XMLRPC Fault Exception: 651 Failed to parse response
}
故障异常:651 解析响应失败,基本上是因为不喜欢格式或数据返回方式。
<br/>
无关。在这里,它是不相关的。解决方案是进行base64编码,但如果您不想这样做,一个简单的\r\n
就可以了。 - Brad