Closed (fixed)
Project:
Mime Mail
Version:
7.x-1.x-dev
Component:
Code
Priority:
Critical
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
5 Jun 2017 at 04:49 UTC
Updated:
24 Aug 2020 at 06:38 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
Lievenvdb commentedMy excuses, I was wrong:
on 19/5/2017 I did the update from the 7.x-1.0 beta4 to 7.x-1.0
Comment #3
Anonymous (not verified) commented+1
Seeing the exact same message when a combination of Message, Message Notify and Rules is sending out email notifications of new content posted to my website.
Like the OP, this has started since updating to the latest stable release.
Comment #4
jotwede commentedI got the same error message after updating the mime mail module from previous version="7.x-1.0-beta4" to version="7.x-1.0". The mails were not sent correctly: the mail body was empty. I re-installed now beta4 again - hoping that this fixes the issue (so long it seems so). I will report here, if this is not the case.
Comment #5
pvasener commentedI experiment the exact same problem (same watchdog message and empty body email) since the upgrade to 1.0. Reverting to 1.0beta fixed the issue.
Comment #6
ZaunerD commentedI managed to reproduce the issue in combination with mimemail_compress and bootstrap.
The offending piece of CSS looks as follows:
This in turn gets nested into the compressed body as follows:
(Note the missing closing bracket)
For whatever reason, the sub-class gets nested into the body style="" attribute; unfortunately, I'm not familiar enough with XPath/DOMDocument to fix it.
The whoopsie happens in file mimemail_compress.inc, lines 157 - 161:
It seems that the new compressor sub-module doesn't play well with bootstrap as there have been other issues with selectors/styles as well, I had to revert to beta4 to resolve it.
Update: here's the relevant bits of my phpinfo():
https://hastebin.com/gupopimaso.rb
Comment #7
neograph734Same issue here, bumping to major (might even be critical). Empty mails are kinda bad...
Comment #8
neograph734Comment #9
kniekel commentedWhen sending out email notifications, about 3 of 20 mails are empty in my case, producing this message. Is there a solution to this problem meanwhile?
Comment #10
scrypter commentedI had to add an if () near line 376 in mimemail.inc to check that there was a match, then plain text emails were no longer blank.
Comment #11
bart lambert commented+1
Using Rules to send mails to users with a role. I'm trying to use SMPT in combination with mimemail (mimemail_smtpmailsystem). This fails due to above error and no mails are sent. Using only mimemail as mailsystem the error occurs but mails are sent correctly anyway.
Any solution on this problem?
Comment #12
neograph734Upping this to critical, module is highly unreliable at the moment.
Comment #13
fantastiko commentedIn my case the similiar error was occured when having "Locale"-module enabled. I wasn't required to have it for my setup, so disabling it fixed the issue.
Comment #14
fmb commentedUsers who choose to receive text-only emails will receive blank messages, because $plaintext is empty in mimemail_html_body() when, for whatever reason, there is no body tag in $body (apparently it happens with the "forgotten password" email, at least for me). scrypter's approach seems fine, see attached patch.
Comment #15
nancydruBetter.
But I still reverted to beta4.
Comment #16
indigoxela commentedI can confirm this behaviour: php notice and empty system mails for users, who set their email to plain-text-only.
mimemail version: 7.x-1.0
And I can confirm that patch #14 applies and fixes the issue.
Comment #17
drupal centric commentedI managed to track down the issue to the head section of my mimemail template, removing the following lines fixed the blank emails for me:
Even though I wasn't trying to insert any css into the head of the email it was breaking it and producing a blank body without a header, only a footer displayed.
Comment #18
zoraxpatch #14 works for me, thank's
Comment #19
Dima DD commentedPatch #14 works for me, too.
However, I've noticed double processing of links placed to the text by the drupal_html_to_text function: duplicates of link numbers (e.g. "url[1][1]") in the original text and progressively increased lists of links in the footnotes.
P.S. Sorry, I think now that this duplication is due to the second procession of plain-text messages by this function in the Views Send module (which I use for bulk sending).
Comment #20
dpierreProblem observed for new content notifications. Does not happen systematically. Maybe only on less than 10% of the notifications which are generated.
Notifications are generated according to rules an roles. Using Drupal 7.56, Rules 7.x-2.10
Reverting MimeMail to beta 4 does not solve the problem. Using patch #14 makes that no notifications are sent anymore.
Is the problem really in MimeMail or in other modules that are also involved in the chain that contributes to generating notification content.
Notifications are sent in html format.
Any idea about where to look?
Comment #21
bbc#14 worked for me as well. In my case the client reported that the body received emails were all blank.
Comment #22
pyrello commentedFWIW, I encountered this issue because I had an implementation of hook_mail that was never setting the body of the message. While this is probably not the case for most of the people on this thread, it is worth noting that something like that can also cause this issue.
Comment #23
nickonom commented#14 took care of the error for me too.
Comment #24
pvasener commentedI confirm that #14 also corrected the problem on my site.
Comment #25
hanskuiters commentedCame across this issue while having the same problem. Using Rules to send mails to all members of an Organic Group. One user has his mail preferences set to plain text only. This user received the mail without the body and an error like the subject of this issue appeared in the log.
Before hitting this issue I already created this attached one line patch to solve the problem.
Comment #26
malcolmp commentedSame issue and #25 fixed it for me.
Comment #27
oniongarlic commentedSerious issue, my users didn't get proper password recovery e-mail if they had selected text-only e-mails in their profile. #25 fixed it.
Comment #28
tr commentedNote the D8 version of Mime Mail requires the same fix, but for a slightly different reason - see #2942376: Undefined offset: 0 in Drupal\mimemail\Utility\MimeMailFormatHelper::mimeMailHtmlBody()
If this issue is important to you, can you please review #2986204: Missing test dependencies so we can get that committed and get the tests working?
The above patch should be checked by the testbot for coding standards problems before being committed. Also, it wouldn't hurt to add a comment to that one-line patch to explain why it's being done so that no-one tries to simplify that piece of code in the future. Likewise, there really should be an added test case to accompany the patch so that we can ensure that future changes to the code don't break this again.
Comment #29
thomas.wardin commentedWhy has this patch not been included in the 1.1 release?
Comment #30
bkosborneBecause 1.1 was a security release. It's a good practice (in my opinion) to ONLY include security related issues in a security release. When you're trying to patch lots of sites, you don't want to have to worry about additional functionality/changes that were bundled in with the security update.
Comment #31
indigoxela commentedWe obviously all failed in setting this issue to the correct status either...
Unfortunately the security update brings back the problem.
Good news though, patch #25 still applies and still solves the problem.
So after updating to 7.x-1.1 (security update), you need to re-apply the patch.
Several users confirmed that the patch works correctly for D7. Setting this to RTBC now.
Comment #32
bbcThanks. #25 worked applied cleanly and addressed the issue as well. Please commit.
Comment #33
mattwmc commentedYep #25 worked for me. Thanks.
Comment #34
joseph.olstadI just upgraded my openatrium and came accross this when sending notices through openatrium to my group members.
+1 , this affects the latest openatrium release that relies on the mimemail module.
The patch works, can someone please jam this in and tag a release?
Comment #35
tr commentedAs I said in #28, this patch needs a comment and a test. Now that we have testing up and working for this module, I'd like to use it.
Comment #36
joseph.olstadTo reproduce this in openatrium:
Create a document with group notification enabled.
When you delete that document an email is sent saying that the document was deleted. The notice of delete email provokes the issue because the preg match is empty.
For the comment I suggest this:
// Correctly validate empty preg match else put a sane default.Comment #37
andraeray commented#25 worked for me. Thanks for posting fix.
In my case it was sending blank bodies for the mail.
Comment #38
Welsby commentedThis warning was also cluttering up my watchdog, #25 sorted it out.
It was getting hit as I'm constructing the e-mails programatically, but for e-mails that I'm blocking (['#send'] = false) I don't bother generating a HTML body, therefore the parameter is empty going into this function as this is called prior to it cancelling the e-mail send.
Comment #39
indigoxela commented@TR if you'd like to have tests, feel free to write them
The patch fixing the problem has been confirmed by several users.
I really don't think documentation or tests should be a show stopper for a critical bug fix. A cleaner approach would be a follow-up issue.
Blocking this patch is very frustrating for people who need it.
Comment #40
ivnishSame problem when I use "plain text only".
#25 worked for me. Thanks!
Comment #41
drummWe’ve run into this on a Drupal.org site, too.
I suspect this was introduced with #2594743: Theme function called for plain messages also. Messages formatted as plain text no longer get a
<body>tag frommimemail-message.tpl.phpComment #42
indigoxela commented@drumm good catch! It's really that simple.
As reportet in 2594743 it "somehow felt wrong" to call the theme function, but actually that's correct and removing that theme call totally broke plain text mails.
The easiest solution for us is to revert those wrong changes. Patch is attached, please review.
Comment #43
indigoxela commentedDear issue followers. One of you should take the time to review the patch #42.
If no one does, the next mimemail release will break plain text mails again.
Comment #44
nickonom commentedI do confirm #42 takes care of the issue.
Comment #45
das-peter commentedAlso just struggled with this issue.
I think approach in #42 looks good.
mimemail_html_body()always treats the passed in body as HTML no matter if the$plainflag is set or not. And it uses the body only if no explicit plaintext was defined.So we shouldn't run in any collisions.
That given,
mimemail_prepare_message()shouldn't change the body based on the plain flag. This also holds true regarding themail_post_processhooks invoked inmimemail_prepare_message()- these hooks don't know if the plain flag was set or not and shouldn't get changing parameters on an opaque flag.As requested by TR in #35 I've added a simple test.
The test only patch should fail - the extended patch from #42 should return green.
Comment #47
drummLooks good to me. The added tests look like they should have good coverage, with and without
$message['params']['plaintext']Comment #48
ndf commentedRTBC +1
Test coverage is good. Very useful for issues like this.
I tested manually that this patch is working on a website that sends with Rules.
That website was previously on beta3. And with this patch I can update it to the newest -dev.
Comment #49
jerdavisRerolled patch from #45 as the update to mimemail.module wasn't applying.
Comment #51
jerdavisComment #52
joseph.olstadThanks @jerdavis, can you please also tag and push a release with this fix?
Comment #53
jerdavisI'd defer to TR on tagging a new release. I'd need to review everything that's gone into 7.x since the last release and understand the implications of tagging a new release of a module in use by 80k "stable" sites. I do agree it should happen.
Comment #55
dd 85 commentedAfter updating the MIME Mail 7.x-1.0 to Mime Mail 7.x-1.1 getting an error
Notice: Undefined offset: 0 in mimemail_html_body() (line 383 in file /sites/all/modules/mimemail/mimemail.inc).
After updating the MIME Mail 7.x-1.0 to Mime Mail 7.x-1.1+8-dev (2019-08-20) getting an error
Notice: Undefined offset: 0 in mimemail_html_body() (line 389 in file /sites/all/modules/mimemail/mimemail.inc).
$plaintext = drupal_html_to_text($matches[0]);
Tried different versions of PHP 5.4, 5.5, 5.6, 7.2, 7.3
The letter comes spoiled.
This happens when the archive is sent to the mail by the Backup and Migrate module of the latest version.
Comment #56
dd 85 commentedComment #57
joseph.olstadWe are still waiting for 7.x-1.2 to be tagged. Please read issues carefully, to get this fix prior to the next tagged release (hasn't happenned yet) you must use a dev release OR patch 1.1 . This fix is only in the dev branch, please
Use the 7.x-1.x-dev release.
This is why I asked 5 months ago for a tagged release , to spare others the trouble.
Comment #58
dd 85 commentedmimemail 7.x-1.x-dev did not help.
Comment #59
kevin morse commentedIs there no way we can get a hotfix for this? It is kind of a big deal that a supposedly stable version of a module used "80k stable sites" is broken...
Comment #60
joseph.olstadKevin, did 7.x-1.x latest dev help? D85 said "no",
Or did you try patching 1.1?
Comment #61
dd 85 commentedmimemail 7.x-1.x-dev works.
But on one of my sites, the problem persists. I assume that this is due to some specific server settings.
Comment #62
joseph.olstad@DD 85,
This module will probably enlighten or solve your debugging on that broken site
Duplicate module fixer
https://www.drupal.org/project/dmf
Remove the incorrect duplicate mimemail module using duplicate module fixer
Comment #63
kevin morse commentedI ended up patching 1.1
It is a really easy fix. Would just be nice if it was built in.