smtp-base64-1741082-16.patch 1.4 KB

12345678910111213141516171819202122232425262728
  1. diff --git a/smtp.mail.inc b/smtp.mail.inc
  2. index 2cf0841..b228e45 100644
  3. --- a/smtp.mail.inc
  4. +++ b/smtp.mail.inc
  5. @@ -367,10 +367,21 @@ class SmtpMailSystem implements MailSystemInterface {
  6. }
  7. // If plain/html within the body part, add it to $mailer->Body.
  8. elseif (strpos($body_part2, 'text/html')) {
  9. + // Get the encoding.
  10. + $body_part2_encoding = $this->_get_substring($body_part2, 'Content-Transfer-Encoding', ' ', "\n");
  11. // Clean up the text.
  12. $body_part2 = trim($this->_remove_headers(trim($body_part2)));
  13. - // Include it as part of the mail object.
  14. - $mailer->Body = $body_part2;
  15. + // Check whether the encoding is base64, and if so, decode it.
  16. + if (drupal_strtolower($body_part2_encoding) == 'base64') {
  17. + // Include it as part of the mail object.
  18. + $mailer->Body = base64_decode($body_part2);
  19. + // Ensure the whole message is recoded in the base64 format.
  20. + $mailer->Encoding = 'base64';
  21. + }
  22. + else {
  23. + // Include it as part of the mail object.
  24. + $mailer->Body = $body_part2;
  25. + }
  26. $mailer->ContentType = 'multipart/mixed';
  27. }
  28. }