Skip to content

Commit

Permalink
Added Quoted-Printable encoding for attachment message bodies. (#28)
Browse files Browse the repository at this point in the history
Thank you for contributing!
  • Loading branch information
dweingart authored and eoghanobrien committed Mar 16, 2018
1 parent 031c0a2 commit 4157250
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
6 changes: 3 additions & 3 deletions class.simple_mail.php
Original file line number Diff line number Diff line change
Expand Up @@ -445,10 +445,10 @@ public function assembleAttachmentBody()
$body = array();
$body[] = "This is a multi-part message in MIME format.";
$body[] = "--{$this->_uid}";
$body[] = "Content-type:text/html; charset=\"utf-8\"";
$body[] = "Content-Transfer-Encoding: 7bit";
$body[] = "Content-Type: text/html; charset=\"utf-8\"";
$body[] = "Content-Transfer-Encoding: quoted-printable";
$body[] = "";
$body[] = $this->_message;
$body[] = quoted_printable_encode($this->_message);
$body[] = "";
$body[] = "--{$this->_uid}";

Expand Down
14 changes: 14 additions & 0 deletions tests/class.simple_mail.test.php
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,20 @@ public function it_filters_angle_brackets_from_emails()
$this->assertEquals($expected, $name);
}

/**
* @test
*/
public function it_qp_encodes_attachment_message_bodies()
{
$message = "J'interdis aux marchands de vanter trop leur marchandises. Car ils se font vite pédagogues et t'enseignent comme but ce qui n'est par essence qu'un moyen, et te trompant ainsi sur la route à suivre les voilà bientôt qui te dégradent, car si leur musique est vulgaire ils te fabriquent pour te la vendre une âme vulgaire.";

$this->mailer->setMessage($message)
->addAttachment($this->directory.'/example/pbXBsZSwgY2hh.jpg', 'lolcat_finally_arrived.jpg');

$body = $this->mailer->assembleAttachmentBody();
$this->assertRegExp('/^Content-Transfer-Encoding: quoted-printable$/m', $body);
}

public function tearDown()
{
unset($this->mailer);
Expand Down

0 comments on commit 4157250

Please sign in to comment.