PHPMailer::encodeQP PHP Method

encodeQP() public method

According to RFC2045 section 6.7.
public encodeQP ( string $string, integer $line_max = 76 ) : string
$string string The text to encode
$line_max integer Number of chars allowed on a line before wrapping
return string
    public function encodeQP($string, $line_max = 76)
    {
        // Use native function if it's available (>= PHP5.3)
        if (function_exists('quoted_printable_encode')) {
            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));
        return preg_replace('/[^\\r\\n]{' . ($line_max - 3) . '}[^=\\r\\n]{2}/', "\$0=\r\n", $string);
    }

Usage Example

示例#1
0
 /**
  * Plain quoted-printable message.
  */
 public function testQuotedPrintable()
 {
     $this->Mail->Body = 'Here is the main body';
     $this->Mail->Subject .= ': Plain + Quoted-printable';
     $this->Mail->Encoding = 'quoted-printable';
     $this->buildBody();
     $this->assertTrue($this->Mail->send(), $this->Mail->ErrorInfo);
     //Check that a quoted printable encode and decode results in the same as went in
     $t = file_get_contents(__FILE__);
     //Use this file as test content
     $this->assertEquals($t, quoted_printable_decode($this->Mail->encodeQP($t)), 'Quoted-Printable encoding round-trip failed');
     $this->assertEquals($this->Mail->encodeQP($t), $this->Mail->encodeQPphp($t), 'Quoted-Printable BC wrapper failed');
 }
All Usage Examples Of PHPMailer::encodeQP