How to fix blank messages on Hotmail

Version 3 Solutions you have discovered or come across should go here. Questions should go in the other three Version 3 forums, thank you.
Forum rules
Please do not ask questions here, this is for Version 3 Solutions you have discovered or come across.

How to fix blank messages on Hotmail

Postby potiron » 8:17am, Thu 12 Sep, 2013

As I sent a message to ~2000 users yesterday, some said to me that they got a blank message. Very bizarre as I tested thoroughly on webmail, yahoo, gmail... obviously not thoroughly as indeed PHPList did not work with Hotmail :evil: !

The result was simple: Blank message received in Hotmail, instead of the HTML version of the newsletter.

Some people reported similar problems in the past, due to embedded images. For me it was not the case. The problem was very similar to the one reported by moc :arrow: HERE.

In a nutshell, it seemed to me that the problem was due to the HTML tags "<" and ">" being replace by Hex 3D characters (=3C...=3D...): for html messages, the method used is Quoted-Printable, where encoding uses hex code prefixed by the equal sign (=).
Yahoo, Webmail and Gmail are fine with it... but hotmail sucks (sorry ! :evil: )

After hours of tries, including the method of using our own SMTP, no success. I tried also using
8bit in admin/init.php
Code: Select all
if (!defined("HTMLEMAIL_ENCODING")) define("HTMLEMAIL_ENCODING","quoted-printable");

but not better.

I found that the problem came form the function EncodeQP in /admin/PHPMailer-5.2.5/class.phpmailer.php. I eventually found a fix, that works ok on Yahoo, Webmail, Outlook Express, Hotmail and Gmail: Ireplace with the previous function (however not the one used in PHPList 2.10.19 where the message was displayed, but the clicktrack urls where broken with a sign "=" inserted inside).
I used the function as coded in PHPMailer 5.1 (23/06/2010):
in /admin/PHPMailer-5.2.5/class.phpmailer.php
Replace
Code: Select all
public function EncodeQP($string, $line_max = 76) {
    if (function_exists('quoted_printable_encode')) { //Use native function if it's available (>= PHP5.3)
      return quoted_printable_encode($string);
    }
    //Fall back to a pure PHP implementation
    $string = str_replace(array('%20', '%0D%0A.', '%0D%0A', '%'), array(' ', "\r\n=2E", "\r\n", '='), rawurlencode($string));
    $string = preg_replace('/[^\r\n]{'.($line_max - 3).'}[^=\r\n]{2}/', "$0=\r\n", $string);
    return $string;
  }

With
Code: Select all
public function EncodeQP($string, $line_max = 76, $space_conv = false) {
      if (function_exists('quoted_printable_encode')) { //Use native function if it's available (>= PHP5.3)
         return quoted_printable_encode($string);
      }
      $filters = stream_get_filters();
      if (!in_array('convert.*', $filters)) { //Got convert stream filter?
         return $this->EncodeQPphp($string, $line_max, $space_conv); //Fall back to old implementation
      }
      $fp = fopen('php://temp/', 'r+');
      $string = preg_replace('/\r\n?/', $this->LE, $string); //Normalise line breaks
      $params = array('line-length' => $line_max, 'line-break-chars' => $this->LE);
      $s = stream_filter_append($fp, 'convert.quoted-printable-encode', STREAM_FILTER_READ, $params);
      fputs($fp, $string);
      rewind($fp);
      $out = stream_get_contents($fp);
      stream_filter_remove($s);
      $out = preg_replace('/^\./m', '=2E', $out); //Encode . if it is first char on a line, workaround for bug in Exchange
      fclose($fp);
      return $out;
   }


PS: I saw the response from duncanc. I think I tried that yesterday and it did not work for me... but I am going to give another try now just to be sure. However my solution presented above works fine so far.
potiron
PL Nut
 
Posts: 19
Joined: 12:38pm, Fri 06 Sep, 2013

Re: How to fix blank messages on Hotmail

Postby potiron » 9:19am, Thu 12 Sep, 2013

Actually I tried again this morning and added in config/config.php:
Code: Select all
# A few people have reported problems with '=' characters being visible in received emails,
# usually with some combination of Hotmail, Outlook and Exchange.
# phplist 3 uses quoted printable as the default encoding whereas phplist 2.10.x uses 8bit,
# so you can revert to the 8bit method

define("HTMLEMAIL_ENCODING","8bit");

with not hack in PHPmailer class... and it works. :P

I thought I tested yesterday, but maybe not exactly this way in the config file, maybe I did it in PHPMailer which had no effet... anyaway, I implemented your simple solution, it's cleaner and then we can keep track for future usage.
potiron
PL Nut
 
Posts: 19
Joined: 12:38pm, Fri 06 Sep, 2013

Re: How to fix blank messages on Hotmail

Postby blo44 » 5:18pm, Sun 29 Sep, 2013

Thanks
blo44
phpLister
 
Posts: 11
Joined: 4:04pm, Sun 29 Sep, 2013

Re: How to fix blank messages on Hotmail

Postby Martin1979 » 1:13pm, Sun 16 Feb, 2014

Hi,

I found a other Problem bei Hotmail.

If you insert tittle in css code in the Html you get the same problem.
/* */ this type of code it's Not working but only with @* *@
Martin1979
phpList newbie
 
Posts: 1
Joined: 4:28pm, Sat 15 Feb, 2014

Re: How to fix blank messages on Hotmail

Postby AleSanchez » 2:31pm, Mon 10 Mar, 2014

I confirm that using
Code: Select all
define("HTMLEMAIL_ENCODING","8bit");

is working for me. PHPList 3.0.0
AleSanchez
phpList newbie
 
Posts: 1
Joined: 2:28pm, Mon 10 Mar, 2014


Return to Answers, HowTos, Tips and Tricks

Who is online

Users browsing this forum: No registered users and 1 guest