Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
307 views
in Technique[技术] by (71.8m points)

php - workaround for the 990 character limitation for email mailservers

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.

The Problem: (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.

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

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

UPDATE:

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

UPDATE #2: Adding MIME Type Code

$headers  = "MIME-Version: 1.0" . "
";
$headers .= "Content-type:text/html;charset=iso-8859-1
";
$headers .= "Content-Transfer-Encoding: quoted-printable
"; // added this, but still no results
$headers .= "From: [email protected]
";

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

How I originally called:

return $html;

What I tried:

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

UPDATE #3 (Adding Mail Function)

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

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
}

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...