public function PHPMailer::EncodeQP in SMTP Authentication Support 7.2
Same name and namespace in other branches
- 5 smtp.module \PHPMailer::EncodeQP()
- 7 smtp.phpmailer.inc \PHPMailer::EncodeQP()
Encode string to RFC2045 (6.7) quoted-printable format Uses a PHP5 stream filter to do the encoding about 64x faster than the old version Also results in same content as you started with after decoding @access public
@author Marcus Bointon
Parameters
string $string the text to encode:
integer $line_max Number of chars allowed on a line before wrapping:
boolean $space_conv Dummy param for compatibility with existing EncodeQP function:
Return value
string
See also
EncodeQPphp()
1 call to PHPMailer::EncodeQP()
- PHPMailer::EncodeString in ./
smtp.phpmailer.inc - Encodes string to requested format. Returns an empty string on failure.
File
- ./
smtp.phpmailer.inc, line 1686 - The mail handler class in smtp module, based on code of the phpmailer library, customized and relicensed to GPLv2.
Class
- PHPMailer
- PHPMailer - PHP email transport class NOTE: Requires PHP version 5 or later @package PHPMailer @author Andy Prevost @author Marcus Bointon @copyright 2004 - 2009 Andy Prevost
Code
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;
}