Update PHPMailer to 5.2.10 from 5.2.7.

Includes two modifications for WordPress:
* Removes support for NTLM in `class-smtp.php` since the required client (`extras/ntlm_sasl_client.php`) is not distributed as part of WordPress.
* Requires `class-smtp.php` for backwards compatibility with direct (non-wp_mail()) uses of PHPMailer, as the autoloader isn't used. See [27385].

This also includes a change to our `MockMailer` for unit tests. It now overrides `postSend() instead of `send()`, and `preSend()`.
`preSend()` resets `$this->Encoding` because PHPMailer doesn't clean up after itself / presets all variables. This becomes an issue when `PHPMailer::createBody()` sets `$this->Encoding = 'quoted-printable'` (away from it's default of 8bit) when it encounters a line longer than 998 characters. `Tests_Comment::test_comment_field_lengths` is such a case.

props MattyRob, dd32.
fixes #28909.

git-svn-id: https://develop.svn.wordpress.org/trunk@33124 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
ocean90 2015-07-08 17:15:02 +00:00
parent 08d5df5f44
commit 94e3540dcc
4 changed files with 1460 additions and 931 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -4,25 +4,23 @@ require_once( ABSPATH . '/wp-includes/class-phpmailer.php' );
class MockPHPMailer extends PHPMailer {
var $mock_sent = array();
function preSend() {
$this->Encoding = '8bit';
return parent::preSend();
}
/**
* Override send() so mail isn't actually sent.
* Override postSend() so mail isn't actually sent.
*/
function send() {
try {
if ( ! $this->preSend() )
return false;
function postSend() {
$this->mock_sent[] = array(
'to' => $this->to,
'cc' => $this->cc,
'bcc' => $this->bcc,
'header' => $this->MIMEHeader,
'body' => $this->MIMEBody,
);
$this->mock_sent[] = array(
'to' => $this->to,
'cc' => $this->cc,
'bcc' => $this->bcc,
'header' => $this->MIMEHeader,
'body' => $this->MIMEBody,
);
return true;
} catch ( phpmailerException $e ) {
return false;
}
return true;
}
}

View File

@ -9,6 +9,20 @@ class Tests_Mail extends WP_UnitTestCase {
unset( $GLOBALS['phpmailer']->mock_sent );
}
/**
* Send a mail with a 1000 char long line.
*
* `PHPMailer::createBody()` will set `$this->Encoding = 'quoted-printable'` (away from it's default of 8bit)
* when it encounters a line longer than 999 characters. But PHPMailer doesn't clean up after itself / presets
* all variables, which means that following tests would fail. To solve this issue we set `$this->Encoding`
* back to 8bit in `MockPHPMailer::preSend`.
*
*/
function test_wp_mail_break_it() {
$content = str_repeat( 'A', 1000 );
wp_mail( "admin@example.org", 'Looong line testing', $content);
}
function test_wp_mail_custom_boundaries() {
$to = 'user@example.com';
$subject = 'Test email with custom boundaries';