diff --git a/class.smtp.php b/class.smtp.php
index 8c609d72..81a85d08 100644
--- a/class.smtp.php
+++ b/class.smtp.php
@@ -631,7 +631,7 @@ class SMTP
if ($in_headers and $line == '') {
$in_headers = false;
}
- //We need to break this line up into several smaller lines
+ //Break this line up into several smaller lines if it's too long
//Micro-optimisation: isset($str[$len]) is faster than (strlen($str) > $len),
while (isset($line[self::MAX_LINE_LENGTH])) {
//Working backwards, try to find a space within the last MAX_LINE_LENGTH chars of the line to break on
diff --git a/examples/contents.html b/examples/contents.html
index 9257f6dd..dc3fc667 100644
--- a/examples/contents.html
+++ b/examples/contents.html
@@ -1,17 +1,17 @@
-
+
PHPMailer Test
-
-
This is a test of PHPMailer.
-
-

-
-
This example uses HTML.
-
The PHPMailer image at the top has been embedded automatically.
+
+
This is a test of PHPMailer.
+
+
+
This example uses HTML.
+
ISO-8859-1 text:
+
diff --git a/examples/contentsutf8.html b/examples/contentsutf8.html
new file mode 100644
index 00000000..81a20240
--- /dev/null
+++ b/examples/contentsutf8.html
@@ -0,0 +1,20 @@
+
+
+
+
+
PHPMailer Test
+
+
+
+
This is a test of PHPMailer.
+
+

+
+
This example uses HTML.
+
Chinese text: 郵件內容為空
+
Russian text: Пустое тело сообщения
+
Armenian text: Հաղորդագրությունը դատարկ է
+
Czech text: Prázdné tělo zprávy
+
+
+
diff --git a/test/phpmailerTest.php b/test/phpmailerTest.php
index c08be0e6..2f871fa5 100644
--- a/test/phpmailerTest.php
+++ b/test/phpmailerTest.php
@@ -149,7 +149,7 @@ class PHPMailerTest extends PHPUnit_Framework_TestCase
$eol = "
\r\n";
$bullet_start = '
';
$bullet_end = "\r\n";
- $list_start = '
\r\n';
+ $list_start = "\r\n";
} else {
$eol = "\r\n";
@@ -166,6 +166,7 @@ class PHPMailerTest extends PHPUnit_Framework_TestCase
$ReportBody .= '---------------------' . $eol;
$ReportBody .= 'phpmailer version: ' . $this->Mail->Version . $eol;
$ReportBody .= 'Content Type: ' . $this->Mail->ContentType . $eol;
+ $ReportBody .= 'CharSet: ' . $this->Mail->CharSet . $eol;
if (strlen($this->Mail->Host) > 0) {
$ReportBody .= 'Host: ' . $this->Mail->Host . $eol;
@@ -210,7 +211,7 @@ class PHPMailerTest extends PHPUnit_Framework_TestCase
}
// Re-attach the original body
- $this->Mail->Body .= $eol . $eol . $ReportBody;
+ $this->Mail->Body .= $eol . $ReportBody;
}
/**
@@ -800,6 +801,29 @@ EOT;
$this->assertNotContains("\r\n\r\nMIME-Version:", $msg, 'Incorrect MIME headers');
}
+ /**
+ * Send a message containing ISO-8859-1 text.
+ */
+ public function testHtmlIso8859()
+ {
+ $this->Mail->isHTML(false);
+ $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');
+ //Make sure it really is in ISO-8859-1!
+ $this->Mail->Body =
+ mb_convert_encoding(
+ $content,
+ "ISO-8859-1",
+ mb_detect_encoding($content, "UTF-8, ISO-8859-1, ISO-8859-15", true)
+ );
+ $this->buildBody();
+ $this->assertTrue($this->Mail->send(), $this->Mail->ErrorInfo);
+ }
+
/**
* Send a message containing multilingual UTF-8 text.
*/
@@ -812,6 +836,7 @@ EOT;
$this->Mail->Body = <<
+
HTML email test
@@ -828,6 +853,41 @@ EOT;
$this->assertNotContains("\r\n\r\nMIME-Version:", $msg, 'Incorrect MIME headers');
}
+ /**
+ * Send a message containing multilingual UTF-8 text with an embedded image.
+ */
+ public function testUtf8WithEmbeddedImage()
+ {
+ $this->Mail->isHTML(true);
+ $this->Mail->Subject .= ": UTF-8 with embedded image";
+ $this->Mail->CharSet = 'UTF-8';
+
+ $this->Mail->Body = <<
+
+
+ HTML email test
+
+
+ Chinese text: 郵件內容為空
+ Russian text: Пустое тело сообщения
+ Armenian text: Հաղորդագրությունը դատարկ է
+ Czech text: Prázdné tělo zprávy
+ Embedded Image:
+
+
+EOT;
+ $this->Mail->addEmbeddedImage(
+ '../examples/images/phpmailer.png',
+ 'my-attach',
+ 'phpmailer.png',
+ 'base64',
+ 'image/png'
+ );
+ $this->buildBody();
+ $this->assertTrue($this->Mail->send(), $this->Mail->ErrorInfo);
+ }
+
/**
* Send a message containing multilingual UTF-8 text.
*/
@@ -854,7 +914,7 @@ EOT;
*/
public function testMsgHTML()
{
- $message = file_get_contents('../examples/contents.html');
+ $message = file_get_contents('../examples/contentsutf8.html');
$this->Mail->CharSet = 'utf-8';
$this->Mail->Body = '';
$this->Mail->AltBody = '';
@@ -904,7 +964,7 @@ EOT;
public function testEmbeddedImage()
{
$this->Mail->Body = 'Embedded Image:
' .
- 'Here is an image!';
+ 'Here is an image!';
$this->Mail->Subject .= ': Embedded Image';
$this->Mail->isHTML(true);