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

Phi*_*ord 7 php character-limit html-email mail-server

想要知道是否有任何函数/类/等...来帮助我的HTML因此而影响电子邮件的990字符限制.

问题:( 来源)

请注意,邮件服务器对电子邮件中包含的每一行都有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";
Run Code Online (Sandbox Code Playgroud)

这是我如何调用函数:

我原来怎么称呼:

return $html;
Run Code Online (Sandbox Code Playgroud)

我尝试了什么:

return imap_8bit($html); // not working, nothing is captured in the error log
Run Code Online (Sandbox Code Playgroud)

return imap_binary($html); // not working, nothing is captured in the error log
Run Code Online (Sandbox Code Playgroud)

更新#3(添加邮件功能)

try {
    mail(
        'to@email.com',
        'Subject of Email',
        $html,
        $headers
        );
    } catch (Exception $e) {
        echo ("ERROR: Email NOT sent, Exception: ".$e->getMessage());
    }
Run Code Online (Sandbox Code Playgroud)

示例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
}
Run Code Online (Sandbox Code Playgroud)

错误异常:651无法解析响应基本上不喜欢格式或数据的返回方式.

jas*_*bar 5

您可以通过wordwrap()函数放置内容,从而不必手动插入换行符。

您是否考虑过使用众多可用的邮件库之一?PHPMailerPEAR MailSwiftMailer等...?