Corrections to ISO text test

Only test ICS configs that are actually supported!
Fix missing headers when using signed messages
This commit is contained in:
Synchro 2015-04-29 20:46:10 +02:00
parent 0635bf672b
commit 9164e6d9eb
2 changed files with 18 additions and 28 deletions

View File

@ -1030,16 +1030,20 @@ class PHPMailer
$this->ContentType = 'multipart/alternative';
}
$this->error_count = 0; // reset errors
$this->error_count = 0; // Reset errors
$this->setMessageType();
// Refuse to send an empty message unless we are specifically allowing it
if (!$this->AllowEmpty and empty($this->Body)) {
throw new phpmailerException($this->lang('empty_message'), self::STOP_CRITICAL);
}
//Create body before headers in case body makes changes to headers (e.g. altering transfer encoding)
// Create body before headers in case body makes changes to headers (e.g. altering transfer encoding)
$this->MIMEHeader = '';
$this->MIMEBody = $this->createBody();
// createBody may have added some headers, so retain them
$tempheaders = $this->MIMEHeader;
$this->MIMEHeader = $this->createHeader();
$this->MIMEHeader .= $tempheaders;
// To capture the complete message when using mail(), create
// an extra header list which createHeader() doesn't fold in

View File

@ -806,21 +806,29 @@ EOT;
*/
public function testHtmlIso8859()
{
$this->Mail->isHTML(false);
$this->Mail->isHTML(true);
$this->Mail->Subject .= ": ISO-8859-1 HTML";
$this->Mail->CharSet = 'iso-8859-1';
//This file is in ISO-8859-1 charset
//Needs to be external because this file is in UTF-8
$content = file_get_contents('../examples/contents.html');
// This is the string 'éèîüçÅñæß' in ISO-8859-1, base-64 encoded
$check = base64_decode('6eju/OfF8ebf');
//Make sure it really is in ISO-8859-1!
$this->Mail->Body =
$this->Mail->msgHTML(
mb_convert_encoding(
$content,
"ISO-8859-1",
mb_detect_encoding($content, "UTF-8, ISO-8859-1, ISO-8859-15", true)
);
),
'../examples'
);
$this->buildBody();
$this->assertTrue(
strpos($this->Mail->Body, $check) !== false,
'ISO message body does not contain expected text'
);
$this->assertTrue($this->Mail->send(), $this->Mail->ErrorInfo);
}
@ -1095,36 +1103,14 @@ EOT;
//Need to test generated output but PHPUnit isn't playing nice
//$rendered = $ICS->render();
//Now test sending an ICS
//Test sending an ICS
$this->Mail->Body = 'This is the <strong>HTML</strong> part of the email.';
$this->Mail->AltBody = 'This is the text part of the email.';
$this->Mail->Subject .= ': iCal';
$this->Mail->isHTML(true);
$this->buildBody();
$ICS = new EasyPeasyICS("PHPMailer test calendar");
$ICS->addEvent(
strtotime('tomorrow 10:00 Europe/Paris'),
strtotime('tomorrow 11:00 Europe/Paris'),
'PHPMailer iCal test',
'A test of PHPMailer iCal support',
'https://github.com/PHPMailer/PHPMailer'
);
$this->Mail->Ical = $ICS->render(false);
$this->assertTrue($this->Mail->send(), $this->Mail->ErrorInfo);
$this->Mail->Body = 'Embedded Image: <img alt="phpmailer" src="cid:my-attach">' .
'Here is an image!</a>.';
$this->Mail->AltBody = 'This is the text part of the email.';
$this->Mail->Subject .= ': iCal + inline';
$this->Mail->isHTML(true);
$this->Mail->addEmbeddedImage(
'../examples/images/phpmailer.png',
'my-attach',
'phpmailer.png',
'base64',
'image/png'
);
$this->buildBody();
$this->assertTrue($this->Mail->send(), $this->Mail->ErrorInfo);
}
/**