From a324b26c7fac2c30d48899329c35d057b207c4ed Mon Sep 17 00:00:00 2001 From: armab Date: Fri, 2 May 2014 17:01:03 +0300 Subject: [PATCH 1/3] BaseMailer: strip
Some content
``` Will look this way in TEXT version of Email: ``` .text-secondary {color: #93959A;} [...] [Other CSS rules] [...] Some content ``` -------------- If TEXT version of Email differs drastically from visible content of HTML version, it can be result that some penalty points will apply to such mails: http://wiki.apache.org/spamassassin/Rules/MPART_ALT_DIFF_COUNT Since it's default behaviour for both yii2-app-advanced and yii2-app-basic (where stripped from tags html used for TextBody), I believe people will stumble in this for sure, without even knowing that their emails can be penalized. You can reproduce it by placing CSS styles in email view or layout and test it here: http://www.mail-tester.com/ (SpamAssassin section). --- framework/mail/BaseMailer.php | 1 + 1 file changed, 1 insertion(+) diff --git a/framework/mail/BaseMailer.php b/framework/mail/BaseMailer.php index 2d3ac2d5aa..872aa8036e 100644 --- a/framework/mail/BaseMailer.php +++ b/framework/mail/BaseMailer.php @@ -186,6 +186,7 @@ abstract class BaseMailer extends Component implements MailerInterface, ViewCont if (isset($text)) { $message->setTextBody($text); } elseif (isset($html)) { + $html = preg_replace('|]*>(.*)|is', '', $html); $message->setTextBody(strip_tags($html)); } } From cdadc01ba297f3718e34574e0a987f3849d94f4c Mon Sep 17 00:00:00 2001 From: armab Date: Fri, 2 May 2014 17:33:25 +0300 Subject: [PATCH 2/3] Update BaseMailer.php --- framework/mail/BaseMailer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/mail/BaseMailer.php b/framework/mail/BaseMailer.php index 872aa8036e..55522cfaea 100644 --- a/framework/mail/BaseMailer.php +++ b/framework/mail/BaseMailer.php @@ -186,7 +186,7 @@ abstract class BaseMailer extends Component implements MailerInterface, ViewCont if (isset($text)) { $message->setTextBody($text); } elseif (isset($html)) { - $html = preg_replace('|]*>(.*)|is', '', $html); + $html = preg_replace('|]*>(.*?)|is', '', $html); $message->setTextBody(strip_tags($html)); } } From 313139968eb75c3fd5128cdfb52f113e6bb7ba71 Mon Sep 17 00:00:00 2001 From: armab Date: Fri, 2 May 2014 18:34:13 +0300 Subject: [PATCH 3/3] Update BaseMailer.php --- framework/mail/BaseMailer.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/framework/mail/BaseMailer.php b/framework/mail/BaseMailer.php index 55522cfaea..ad805f3f14 100644 --- a/framework/mail/BaseMailer.php +++ b/framework/mail/BaseMailer.php @@ -186,6 +186,9 @@ abstract class BaseMailer extends Component implements MailerInterface, ViewCont if (isset($text)) { $message->setTextBody($text); } elseif (isset($html)) { + if (preg_match('|]*>(.*?)|is', $html, $match)) { + $html = $match[1]; + } $html = preg_replace('|]*>(.*?)|is', '', $html); $message->setTextBody(strip_tags($html)); }