Search code examples
phpphpmailer

PHPMailer inserts '=' equal sign every 75th character


Using PHPMailer 5.2.14, emails are sent in text/html. The outgoing text is littered with equal signs every 75th character.

I tried using the EOL workaround, but it did not remove the extra equal signs:

$email = new PHPMailer();
$email->From      = '[email protected]';
$email->FromName  = 'FromUser';
$email->AddAddress( '[email protected]' );
$email->Subject   = 'This is a test';
$email->IsHTML(true);
$email->Body = "<p>This is a test.&nbsp; This is a test.&nbsp; This is a test.&nbsp; This is a test.&nbsp; This is a test.&nbsp; This is a test.&nbsp; This is a test.&nbsp; This is a test.&nbsp; This is a test.&nbsp; This is a test.&nbsp; This is a test.&nbsp; This is a test.&nbsp; This is a test.&nbsp; This is a test.&nbsp; </p>";

// fix EOL here? 
$email->LE = PHP_EOL;

$email->Send();

Resulting source upon receipt:

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><font face="arial"><base href="http://example.com/"><!-- </base> -->=
<p>This is a test.&nbsp; This is a test.&nbsp; This is a test.&nbsp; This i=
s a test.&nbsp; This is a test.&nbsp; This is a test.&nbsp; This is a test.=
&nbsp; This is a test.&nbsp; This is a test.&nbsp; This is a test.&nbsp; Th=
is is a test.&nbsp; This is a test.&nbsp; This is a test.&nbsp; This is a t=
est.&nbsp; This is a test.&nbsp; This is a test.&nbsp; This is a test.&nbsp;=
 </p></font>

The equal signs appear when viewing in Outlook. When I send the same text/html to a gmail account, the equal signs are not present.

What needs to happen to eliminate these stray equal signs for recipients using Outlook?


Solution

  • I had the same problem with html-emails in PHPMailer. I've tested different things and found out:

    • The problem happens if the message has a special length - in my case >1002 letters in one line (when I have removed some letters (irrelevant which ones) the email was correct)
    • The problem is visible only in some email-programms (e.g. MS Outlook, website t-online.de; no problems with yahoo)
    • I've testet PHPMailer 5.2.7 - 5.2.14: The problem exists in PHPMailer >5.2.10 (no problems in PHPMailer 5.2.7 - 5.2.10)
    • Solutions like '$mail->Encoding = "7bit";' or '$mail->LE = PHP_EOL;' didn't worked for me
    • No Problems when sending the email via isSmtp().
    • Tested on two different servers: Server 1 contains equal signs, Server 2 doesn't contain that signs but has wrong linebreaks - the php-configuration on both servers is nearly identical > it doesn't seem to be a php-problem

    So for me the solution was "take PHPMailer 5.2.10" till they solve the problem in a newer version - No good solution, but it works for me till I find a better one ;-)