Skip to content

Commit

Permalink
Change Encoding of MIME Emails to QUOTED-PRINTABLE
Browse files Browse the repository at this point in the history
Added Content-Disposition: inline to all MIME emails

Implementation now matches previous ZF1 implementation
  • Loading branch information
Graham Wharton committed Jul 11, 2019
1 parent ede25ae commit 226009e
Show file tree
Hide file tree
Showing 14 changed files with 21 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -771,7 +771,7 @@ public function testConfirmationEmailWithSpecialCharacters(): void

$this->assertContains('To: ' . $email, $rawMessage);

$content = $message->getBody()->getPartContent(0);
$content = $message->getBody()->getParts()[0]->getRawContent();
$confirmationUrl = $this->getConfirmationUrlFromMessageContent($content);
$this->setRequestInfo($confirmationUrl, 'confirm');
$this->clearCookieMessagesList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@

use Magento\TestFramework\Mail\Template\TransportBuilderMock;

/**
* \Magento\Newsletter\Model\Subscriber tests
*/
class SubscriberTest extends \PHPUnit\Framework\TestCase
{
/**
Expand Down Expand Up @@ -35,7 +38,7 @@ public function testEmailConfirmation()
$this->assertContains(
'/newsletter/subscriber/confirm/id/' . $this->model->getSubscriberId()
. '/code/ysayquyajua23iq29gxwu2eax2qb6gvy',
$transportBuilder->getSentMessage()->getRawMessage()
$transportBuilder->getSentMessage()->getBody()->getParts()[0]->getRawContent()
);
$this->assertEquals(Subscriber::STATUS_NOT_ACTIVE, $this->model->getSubscriberStatus());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public function testSendEmailOnOrderSave(): void
);

$this->assertEquals($message->getSubject(), $subject);
$this->assertThat($message->getRawMessage(), $assert);
$this->assertThat($message->getBody()->getParts()[0]->getRawContent(), $assert);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function testSendEmailOnAddCreditmemoComment(): void
);

$this->assertEquals($message->getSubject(), $subject);
$this->assertThat($message->getRawMessage(), $messageConstraint);
$this->assertThat($message->getBody()->getParts()[0]->getRawContent(), $messageConstraint);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function testSendEmailOnCreditmemoSave(): void
);

$this->assertEquals($message->getSubject(), $subject);
$this->assertThat($message->getRawMessage(), $messageConstraint);
$this->assertThat($message->getBody()->getParts()[0]->getRawContent(), $messageConstraint);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function testSendOrderEmail(): void
);

$this->assertEquals($message->getSubject(), $subject);
$this->assertThat($message->getRawMessage(), $assert);
$this->assertThat($message->getBody()->getParts()[0]->getRawContent(), $assert);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function testSendEmailOnAddInvoiceComment(): void
);

$this->assertEquals($message->getSubject(), $subject);
$this->assertThat($message->getRawMessage(), $messageConstraint);
$this->assertThat($message->getBody()->getParts()[0]->getRawContent(), $messageConstraint);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function testSendInvoiceEmail(): void
);

$this->assertEquals($message->getSubject(), $subject);
$this->assertThat($message->getRawMessage(), $messageConstraint);
$this->assertThat($message->getBody()->getParts()[0]->getRawContent(), $messageConstraint);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function testSendEmailOnInvoiceSave(): void
);

$this->assertEquals($message->getSubject(), $subject);
$this->assertThat($message->getRawMessage(), $messageConstraint);
$this->assertThat($message->getBody()->getParts()[0]->getRawContent(), $messageConstraint);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,6 @@ public function testSendEmailOnOrderPlace(): void
);

$this->assertEquals($message->getSubject(), $subject);
$this->assertThat($message->getRawMessage(), $assert);
$this->assertThat($message->getBody()->getParts()[0]->getRawContent(), $assert);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function testSendEmailOnShipmentCommentAdd(): void
);

$this->assertEquals($message->getSubject(), $subject);
$this->assertThat($message->getRawMessage(), $messageConstraint);
$this->assertThat($message->getBody()->getParts()[0]->getRawContent(), $messageConstraint);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function testSendEmailOnShipmentSave(): void
);

$this->assertEquals($message->getSubject(), $subject);
$this->assertThat($message->getRawMessage(), $messageConstraint);
$this->assertThat($message->getBody()->getParts()[0]->getRawContent(), $messageConstraint);
}

/**
Expand Down
2 changes: 2 additions & 0 deletions lib/internal/Magento/Framework/Mail/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ private function createMimeFromString($body, $messageType)
{
$part = new Part($body);
$part->setCharset($this->zendMessage->getEncoding());
$part->setEncoding(Mime::ENCODING_QUOTEDPRINTABLE);
$part->setDisposition(Mime::DISPOSITION_INLINE);
$part->setType($messageType);
$mimeMessage = new \Zend\Mime\Message();
$mimeMessage->addPart($part);
Expand Down
6 changes: 4 additions & 2 deletions lib/internal/Magento/Framework/Mail/Test/Unit/MessageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ public function testSetBodyHtml()

$part = $this->message->getBody()->getParts()[0];
$this->assertEquals('text/html', $part->getType());
$this->assertEquals('8bit', $part->getEncoding());
$this->assertEquals('quoted-printable', $part->getEncoding());
$this->assertEquals('utf-8', $part->getCharset());
$this->assertEquals('body', $part->getContent());
$this->assertEquals('inline', $part->getDisposition());
}

public function testSetBodyText()
Expand All @@ -37,8 +38,9 @@ public function testSetBodyText()

$part = $this->message->getBody()->getParts()[0];
$this->assertEquals('text/plain', $part->getType());
$this->assertEquals('8bit', $part->getEncoding());
$this->assertEquals('quoted-printable', $part->getEncoding());
$this->assertEquals('utf-8', $part->getCharset());
$this->assertEquals('body', $part->getContent());
$this->assertEquals('inline', $part->getDisposition());
}
}

0 comments on commit 226009e

Please sign in to comment.