Problem/Motivation
Plain text email constructed with mail.inc will trigger several SpamAssassin mixed case URI tests. Any MTA that has those filters enabled will flag mail from Drupal as spam (if they are all enabled, it can add up to a very, very high spam score); some of those tests are HTTP_MIXC BODY, URI_TLD_MIXC URI, and URI_PROTO_MIXC URI.
These tests are not enabled by default, and it is possibly a questionable decision to have them enabled, at all, but some relatively large mail servers do (I get bounces every few days due to it, when I forget the patch my mail.inc after a Drupal update; we send out a few thousand notification emails a day).
The offending lines are:
// Fancy headers
case 'h1':
$indent[] = '======== ';
$casing = 'drupal_strtoupper';
break;
case 'h2':
$indent[] = '-------- ';
$casing = 'drupal_strtoupper';
break;
Simply removing the "$casing = 'drupal_strtoupper';" lines resolves this problem. It also makes plain text email slightly less ugly (all caps is obnoxious, regardless of its problems triggering spam filters).
Note that this also overrides templates and such, without any configurable options to avoid it, which seems unfriendly.
The problem has been present for most of forever. It is in both our 6.x production site and 7.x development site.
Proposed resolution
- Remove
mb_strtoupper
from the h1 and h2 tags in MailFormatHelper.php::htmlToText() method
Remaining tasks
- Review
- Commit
User interface changes
API changes
Data model changes
Release notes snippet
Comment | File | Size | Author |
---|---|---|---|
#20 | interdiff-18-20.txt | 3.32 KB | Hardik_Patel_12 |
#20 | 2414019-20.patch | 5.13 KB | Hardik_Patel_12 |
#4 | keep_case_in_plain_text_mail-2414019-4-d8.patch | 1.72 KB | mpp |
Comments
Comment #1
swelljoe CreditAttribution: swelljoe as a volunteer commentedThis problem still exists in Drupal 8.0-rc4. In fact, it's had some attention by someone to keep the misfeature working as always, as it has been rewritten to support the new Drupal Unicode stuff.
Am I wrong for not wanting spam filters to reject mail from my Drupal installation (and to not have capslock imposed on every mail out of a Drupal system)? Can this at least be made configurable or easier to override without patching core?
I've attached a patch to remove the forced caps. I'd be willing to make it configurable, if there were some indication it'd be included, and if given feedback on where such an option should be added.
If I'm filing against the wrong component, please let me know.
Comment #2
swelljoe CreditAttribution: swelljoe as a volunteer commentedComment #3
mpp CreditAttribution: mpp as a volunteer and at AmeXio commentedMakes sense. Triggering testbot.
Comment #4
mpp CreditAttribution: mpp as a volunteer and at AmeXio commentedCompletely removed the $casing variable/concept.
Comment #5
mpp CreditAttribution: mpp as a volunteer and at AmeXio commentedComment #6
mpp CreditAttribution: mpp as a volunteer and at AmeXio commentedComment #7
mpp CreditAttribution: mpp as a volunteer and at AmeXio commentedComment #8
mpp CreditAttribution: mpp as a volunteer and at AmeXio commentedComment #16
jungleComment #17
jungleComment #18
Hardik_Patel_12 CreditAttribution: Hardik_Patel_12 at QED42 for Drupal India Association commentedRe-rolled against 9.1.x , kindly review.
Comment #20
Hardik_Patel_12 CreditAttribution: Hardik_Patel_12 at QED42 for Drupal India Association commentedSolving failed test case , kindly review.
Comment #22
quietone CreditAttribution: quietone as a volunteer commentedThe patch still applies to 9.2.x. On a brief look the patch looks fines and there is a test. Just a few items needed to move this along.
Not all the items in #16 have been completed. Added those to the remaining tasks section of the IS. The first two items are novice level tasks, so adding 'novice' tag.
Comment #23
mohit_aghera CreditAttribution: mohit_aghera at QED42 commented- Remove mail.inc reference from the title.
- Update the proposed solution section of the issue.
Changing status to Needs review for reviewers.
Comment #24
mohit_aghera CreditAttribution: mohit_aghera at QED42 commentedComment #25
quietone CreditAttribution: quietone as a volunteer commented@mohit_aghera, thanks!
Looking at this again, and a bit of converstaion with jibran in #bugsmash, I think this is a good idea. It seems really odd to me that we are changing the case of text constructed by someone. They took care to create the header and we should not be changing that. The addition of the indentation and either the '=' or '-' character is sufficient to notify the reader of the plain text mail that this is 'section' of text.
The patch still applies and I reviewed the code. And we can now removing $casing as it is no longer used. The test changes look fine to me.
Comment #28
catchMakes sense, I checked to see how long the uppercasing has been in there, and it's more than 14 years.
Committed 3d23f22 and pushed to 9.2.x. Thanks! Also cherry-picked to 9.1.x