Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
After upgrading to Drupal 7.20 inline images which are output using an image style (e.g. thumbnail, medium, large, etc) are not correctly inlined in the email, rather they are just available as attachments and then do not appear inline.
So far I've been able to trace it back to Mail_Mime PEAR class. Still no solution as of yet.
Comment | File | Size | Author |
---|---|---|---|
#1 | mailmime-fix_inline_images_1929678-1.patch | 698 bytes | fenstrat |
Comments
Comment #1
fenstratTurns out the issue is with mailmime and specifically the name of the inline image which must include the itok=xxx query string parameter. Without this inline images using output using image_style's only ever get attached, not included inline in the email body.
Comment #2
salvisThank you for your analysis and patch.
Can someone review and confirm this, please?
Comment #3
fenstratNo worries @salvis.
For anyone reviewing this, it wont effect images not output using image_style - they'll be inlined as per normal. This patch should only effect image_style images and allows them to be inlined in Drupal 7.20+
Comment #4
salvisI would really like to create new releases for Mail MIME, but we have three patches in the queue that should probably be committed:
#1813542: Multipart/Alternative with line break (introduced by PEAR) breaks drupal core and results in unreadable message (D6 — what about D7???)
#1929678: Mail MIME inline images using image_style's do not work with Drupal 7.20 (D7, maybe D6, too)
#1935610: url_to_realpath fix (D7, maybe D6, too)
I'm not using Mail MIME myself, and I need someone to review these patches. Maybe the three authors could trade reviews? Or someone else who is actively using Mail MIME?
Comment #5
fenstratTo test this simply include an image output via an image_style in an email for sending. Without the patch in #1 that image will not be correctly inlined in the email.
Comment #6
starlocke CreditAttribution: starlocke commentedI have 'htmlmail' installed, so there's a handy send-mail test page at http(s)://www.example.com/admin/config/system/htmlmail/test
Comment #7
fenstrat@starlocke So did the patch in #1 work for you?
Comment #8
DuaelFrThanks for this patch !
It is working very well.
Comment #9
salvisHad to massage the patch a little to get it to apply. Committed to 7.x-2.x-dev.
Thanks, DuaelFr!
Does this need to be backported to 6.x-2.x-dev?
Comment #10
salvisLet's put it this way:
I'd like to create a new releases for Mail MIME for D6, too, but we have two D7 patches in the queue which may or may not need to be back-ported to D6:
#1929678: Mail MIME inline images using image_style's do not work with Drupal 7.20 (this one)
#1935610: url_to_realpath fix
I'm not using Mail MIME myself, and I need people to either port and review, or to tell me that the patches are not needed for D6.
Comment #11
salvisPorting to D6 is not going to happen anymore, so we'll let this RIP.
Comment #12
salvis@fenstrat and all:
It seems that this patch is causing problems for some email clients, because they get confused by the query string.
There is a new patch in #2527712: Embedded images are attached with bad names., essentially proposing to undo this one.
Can you explain why the querystring needs to go out to the email client? After all, the images with the proper style are embedded in the email, so the image_style should not matter anymore...
Comment #13
fenstratFrom memory without itok=xxx (i.e. what was added here in #1) if the image style derivative does not exist it will not get generated. That leads to broken images in all email clients.