-
Notifications
You must be signed in to change notification settings - Fork 9.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[2.3] Transfer Encoding of emails changed to QUOTED-PRINTABLE #23649
[2.3] Transfer Encoding of emails changed to QUOTED-PRINTABLE #23649
Conversation
Hi @gwharton. Thank you for your contribution
For more details, please, review the Magento Contributor Assistant documentation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm also struggling to find where earlier versions used quoted-printable for the message body. The magento fork for ZF1 looks to have the same default as what is currently used. ZF1 was using quoted-printable for encoding headers and that does seem to be missing from the current ZF2 implementation. |
Take a look at the ZF1 Zend_Mail class here. https://github.com/magento/zf1/blob/master/library/Zend/Mail.php#L362-L377 and https://github.com/magento/zf1/blob/master/library/Zend/Mail.php#L404-L419 which are the setBodyText and setBodyHtml functions from ZF1. In Magento 2.2.7, /Magento/Framework/Mail/Message.php inherited from Zend_Mail. With the move to ZF2, these two functions were effectively moved into /Magento/Framework/Mail/Message.php. It could also be argued that Zend_Mime::DISPOSITION_INLINE should also be set, as that was also the default in ZF1. |
With request to the test failures, I'm not at all sure what to do. The tests are failing because encoding the email with quoted-printable, results in an email which has the body split into multiple lines with CRLF at the end of each line. Thus tests that are looking for strings in the email body fail because in many cases the string that is being looked for has a CRLF inserted into it, if it spans a line boundary. I'll see if I can find out why these tests were passing under 2.2 which did encode emails in this way. |
OK, i've had to modify the failing integration tests to get them to pass. They were originally written to use the \Zend\Message::getRawMessage function to get the body of the email message, but this function returns the email body encoded. Thus now that the emails are changed to encoding quoted-printable, the raw message returned in the test is encoded and the tests fail. The tests have been modified to use the \Zend\Mime\Part::getRawContent() instead which returns the email body unencoded, allowing the tests to pass. Just waiting on the green lights from the automated tests. Let me know if you think Zend_Mime::DISPOSITION_INLINE should also be applied, and whether you want me to do anything with the header encoding. Makes sense to get all these in together. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's set the disposition to \Zend\Mime::DISPOSITION_INLINE
. I took a deeper look at the ZF2 header encoding and they are already quoted-printable so we should be good there.
Added Content-Disposition: inline to all MIME emails Implementation now matches previous ZF1 implementation
Backport is here #23650 |
Hi @pmclain, thank you for the review.
|
✔️ QA passed |
Hi @gwharton, thank you for your contribution! |
Description (*)
When Magento used Zend Framework 1 for emails, MIME emails were sent with Transfer Encoding set to QUOTED-PRINTABLE. This means that emails with long lines (particularly emails with large inline css) are encoded properly. This can be confirmed by running tests under 2.2.7.
When Magento switched to Zend Framework 2, the default Transfer Encoding was set to 8-bit. This emails with long lines were being rejected by some mail servers as they were not encoded quoted-printable as expected.
Magento 2.2.8+ and 2.3.0+ are affected by this.
This PR changes the default encoding of all MIME emails to quoted-printable.
Fixed Issues (if relevant)
Manual testing scenarios (*)
Contribution checklist (*)