diff --git a/lib/classes/component.php b/lib/classes/component.php
index 277d7db6942..ec6c3ad6b9b 100644
--- a/lib/classes/component.php
+++ b/lib/classes/component.php
@@ -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',
);
/**
diff --git a/lib/moodlelib.php b/lib/moodlelib.php
index d701062b899..22dfc207d97 100644
--- a/lib/moodlelib.php
+++ b/lib/moodlelib.php
@@ -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;
diff --git a/lib/phpmailer/README_MOODLE.txt b/lib/phpmailer/README_MOODLE.txt
index b9ddfac48c8..d87a202780a 100644
--- a/lib/phpmailer/README_MOODLE.txt
+++ b/lib/phpmailer/README_MOODLE.txt
@@ -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
\ No newline at end of file
diff --git a/lib/phpmailer/moodle_phpmailer.php b/lib/phpmailer/moodle_phpmailer.php
index 63abdeb7254..d1b58c66208 100644
--- a/lib/phpmailer/moodle_phpmailer.php
+++ b/lib/phpmailer/moodle_phpmailer.php
@@ -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.
*
diff --git a/lib/thirdpartylibs.xml b/lib/thirdpartylibs.xml
index ce97f483e9b..73fb6948e82 100644
--- a/lib/thirdpartylibs.xml
+++ b/lib/thirdpartylibs.xml
@@ -116,7 +116,7 @@
phpmailer
PHPMailer
LGPL
- 5.2.23
+ 6.0.1
2.1
diff --git a/version.php b/version.php
index a8c58ddd6fb..0a6f2d6f3f8 100644
--- a/version.php
+++ b/version.php
@@ -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.