Few chars getting replaced with ‘=’ in mail content in wp_mail()

Commenting couple of return statements and replacing them as suggested in the below link on wordpress.org worked for me, now the mails are sent properly and the equal sign ‘=’ issue is solved.

Fixed by making following changes in wp-includes\class-phpmailer.php

public function encodeQP($string, $line_max = 76)
    {
        // Use native function if it's available (>= PHP5.3)
        if (function_exists('quoted_printable_encode')) {
            //return $this->fixEOL(quoted_printable_encode($string)); commented this one
            return quoted_printable_encode($string); // added this line
        }
        // 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 $this->fixEOL($string); commented this one
        return $string; // added this line
    }

Read more here: https://core.trac.wordpress.org/ticket/33815

Leave a Comment