gpt4 book ai didi

php - 电子邮件邮件服务器 990 个字符限制的解决方法

转载 作者:可可西里 更新时间:2023-11-01 13:21:53 26 4
gpt4 key购买 nike

想知道是否有任何函数/类/等..可以帮助解决电子邮件的 990 个字符限制,因为我的 HTML 正因此受到影响。

问题:(Source)

Note that mailservers have a 990-character limit on each line contained within an email message. If an email message is sent that contains lines longer than 990-characters, those lines will be subdivided by additional line ending characters, which can cause corruption in the email message, particularly for HTML content. To prevent this from occurring, add your own line-ending characters at appropriate locations within the email message to ensure that no lines are longer than 990 characters.

其他人似乎也有这个问题?你是如何解决这个问题的?

听起来我需要找个好地方来拆分我的 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

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
}

Fault Exception: 651 Failed to parse response 基本上不喜欢格式或返回数据的方式。

最佳答案

你可以把你的内容通过wordwrap()功能,这样您就不必手动插入换行符。

您是否考虑过使用众多可用的邮件库之一? PHPMailer , PEAR Mail , SwiftMailer等等……?

关于php - 电子邮件邮件服务器 990 个字符限制的解决方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4738160/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com