mirror of
https://github.com/moodle/moodle.git
synced 2025-04-13 20:42:22 +02:00
MDL-60194 lib: Internal changes by Moodle to phpmailer.
This commit is contained in:
parent
d8e9a23c48
commit
56e62bbba1
@ -84,6 +84,7 @@ class core_component {
|
||||
'MatthiasMullie\\PathConverter' => 'lib/minify/matthiasmullie-pathconverter/src/',
|
||||
'IMSGlobal\LTI' => 'lib/ltiprovider/src',
|
||||
'Phpml' => 'lib/mlbackend/php/phpml/src/Phpml',
|
||||
'PHPMailer\\PHPMailer' => 'lib/phpmailer/src',
|
||||
);
|
||||
|
||||
/**
|
||||
|
@ -5579,7 +5579,7 @@ function get_mailer($action='get') {
|
||||
// Use SMTP directly.
|
||||
$mailer->isSMTP();
|
||||
if (!empty($CFG->debugsmtp)) {
|
||||
$mailer->SMTPDebug = true;
|
||||
$mailer->SMTPDebug = 3;
|
||||
}
|
||||
// Specify main and backup servers.
|
||||
$mailer->Host = $CFG->smtphosts;
|
||||
|
@ -1,21 +1,24 @@
|
||||
Description of PHPMailer 5.2.23 library import into Moodle
|
||||
Description of PHPMailer 6.0.1 library import into Moodle
|
||||
|
||||
We now use a vanilla version of phpmailer and do our customisations in a
|
||||
subclass.
|
||||
|
||||
When doing the import we remove directories/files:
|
||||
aboutus.html
|
||||
class.pop3.php
|
||||
class.phpmailer.oauth.php
|
||||
class.phpmailer.oauthgoogle.php
|
||||
get_oauth_token.php
|
||||
.travis.yml
|
||||
.scrutinizer.yml
|
||||
composer.json
|
||||
composer.lock
|
||||
travis.phpunit.xml.dist
|
||||
PHPMailerAutoload.php (make sure all files are included in moodle_phpmailer.php)
|
||||
.github/
|
||||
.phan/
|
||||
docs/
|
||||
examples/
|
||||
src/OAuth.php
|
||||
src/POP3.php
|
||||
test/
|
||||
extras/
|
||||
.gitattributes
|
||||
.gitignore
|
||||
.php_cs
|
||||
.scrutinizer.yml
|
||||
.travis.yml
|
||||
SECURITY.md
|
||||
UPGRADING.md
|
||||
composer.json
|
||||
get_oauth_token.php
|
||||
phpdoc.dist.xml
|
||||
travis.phpunit.xml.dist
|
@ -27,9 +27,6 @@ defined('MOODLE_INTERNAL') || die();
|
||||
// PLEASE NOTE: we use the phpmailer class _unmodified_
|
||||
// through the joys of OO. Distros are free to use their stock
|
||||
// version of this file.
|
||||
// NOTE: do not rely on phpmailer autoloader for performance reasons.
|
||||
require_once($CFG->libdir.'/phpmailer/class.phpmailer.php');
|
||||
require_once($CFG->libdir.'/phpmailer/class.smtp.php');
|
||||
|
||||
/**
|
||||
* Moodle Customised version of the PHPMailer class
|
||||
@ -42,7 +39,7 @@ require_once($CFG->libdir.'/phpmailer/class.smtp.php');
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @since Moodle 2.0
|
||||
*/
|
||||
class moodle_phpmailer extends PHPMailer {
|
||||
class moodle_phpmailer extends \PHPMailer\PHPMailer\PHPMailer {
|
||||
|
||||
/**
|
||||
* Constructor - creates an instance of the PHPMailer class
|
||||
@ -61,9 +58,9 @@ class moodle_phpmailer extends PHPMailer {
|
||||
|
||||
// Some MTAs may do double conversion of LF if CRLF used, CRLF is required line ending in RFC 822bis.
|
||||
if (isset($CFG->mailnewline) and $CFG->mailnewline == 'CRLF') {
|
||||
$this->LE = "\r\n";
|
||||
parent::setLE("\r\n");
|
||||
} else {
|
||||
$this->LE = "\n";
|
||||
parent::setLE("\n");
|
||||
}
|
||||
}
|
||||
|
||||
@ -97,9 +94,9 @@ class moodle_phpmailer extends PHPMailer {
|
||||
$chunks = array_map(function($chunk) {
|
||||
return addcslashes($chunk, "\0..\37\177\\\"");
|
||||
}, $chunks);
|
||||
return '"' . join($this->LE, $chunks) . '"';
|
||||
return '"' . join(parent::getLE(), $chunks) . '"';
|
||||
}
|
||||
return str_replace("\n", $this->LE, $encoded);
|
||||
return str_replace("\n", parent::getLE(), $encoded);
|
||||
}
|
||||
|
||||
return parent::encodeHeader($str, $position);
|
||||
@ -119,33 +116,6 @@ class moodle_phpmailer extends PHPMailer {
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* This is a temporary replacement of the parent::EncodeQP() that does not
|
||||
* call quoted_printable_encode() even if it is available. See MDL-23240 for details
|
||||
*
|
||||
* @see parent::EncodeQP() for full documentation
|
||||
*/
|
||||
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);
|
||||
//}
|
||||
$filters = stream_get_filters();
|
||||
if (!in_array('convert.*', $filters)) { //Got convert stream filter?
|
||||
return parent::encodeQP($string, $line_max); //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 $this->fixEOL($out);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends this mail.
|
||||
*
|
||||
|
@ -116,7 +116,7 @@
|
||||
<location>phpmailer</location>
|
||||
<name>PHPMailer</name>
|
||||
<license>LGPL</license>
|
||||
<version>5.2.23</version>
|
||||
<version>6.0.1</version>
|
||||
<licenseversion>2.1</licenseversion>
|
||||
</library>
|
||||
<library>
|
||||
|
@ -29,7 +29,7 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$version = 2017100600.00; // YYYYMMDD = weekly release date of this DEV branch.
|
||||
$version = 2017100600.01; // YYYYMMDD = weekly release date of this DEV branch.
|
||||
// RR = release increments - 00 in DEV branches.
|
||||
// .XX = incremental changes.
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user