电子邮件邮件服务器的990个字符限制的解决方法 [英] workaround for the 990 character limitation for email mailservers

查看:279
本文介绍了电子邮件邮件服务器的990个字符限制的解决方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Wanted to know if there are any functions/classes/etc.. to help with the 990 character limitation for email as my HTML is being effected due to this.

问题:()

请注意,邮件服务器有一个 每行最多990个字符 包含在电子邮件中.如果 发送一封电子邮件,其中包含 超过990个字符的行, 这些行将细分为 其他行尾字符, 可能会导致 电子邮件,尤其是HTML 内容.为了防止这种情况 发生时,添加您自己的行尾 适当位置的字符 在电子邮件中以确保 没有任何行长于990 字符.

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.

还有其他人似乎有这个问题吗?以及您如何解决此问题?

Anyone else seem to have this problem? and how did you fix this?

听起来像我需要找到一个拆分HTML并手动添加换行符的好地方,嗯...

Sounds like I need to find a good place to split my HTML and manually add a line break, ugh...

更新:

它是具有许多行的制表数据.那我需要在某个地方添加\ n或<br />吗?

It's tablature data with many rows. So do I need to add a \n or <br /> somewhere?

更新#2:添加MIME类型代码

UPDATE #2: Adding MIME Type Code

$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";

这是我调用函数的方式:

Here is how I'm calling the function(s):

我最初的称呼方式:

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(添加邮件功能)

UPDATE #3 (Adding Mail Function)

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

示例HTML(这是HTML电子邮件的消息)(这也在XMLRPC服务的一部分的类中)

Example HTML (This is the message of the HTML email) (This is also in a class that is part of a XMLRPC service)

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无法解析响应,基本上不喜欢格式或数据返回方式.

Fault Exception: 651 Failed to parse response basically doesn't like the format or how the data is returned.

推荐答案

您可以通过 wordwrap()放置内容函数,这样您就不必手动插入换行符.

You can put your content through the wordwrap() function so that you don't manually have to insert newlines.

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

Have you considered using one of the many mail libraries available? PHPMailer, PEAR Mail, SwiftMailer, etc...?

这篇关于电子邮件邮件服务器的990个字符限制的解决方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆