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.

Members fund testing for the Drupal project. Drupal Association Learn more


fenstrat’s picture

Title: HTML Mail inline images using image_style's do not work with Drupal 7.20 » Mail MIME inline images using image_style's do not work with Drupal 7.20
Project: HTML Mail » Mail MIME
Priority: Normal » Major
Status: Active » Needs review
698 bytes

Turns 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.

salvis’s picture

Thank you for your analysis and patch.

Can someone review and confirm this, please?

fenstrat’s picture

No 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+

salvis’s picture

I 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?

fenstrat’s picture

To 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.

starlocke’s picture

I have 'htmlmail' installed, so there's a handy send-mail test page at http(s)://

// A test HTML e-mail body

<img src="http(s)://" />

With get param:
<img src="http(s)://" />
fenstrat’s picture

@starlocke So did the patch in #1 work for you?

DuaelFr’s picture

Status: Needs review » Reviewed & tested by the community

Thanks for this patch !
It is working very well.

salvis’s picture

Status: Reviewed & tested by the community » Fixed

Had 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?

salvis’s picture

Version: 7.x-2.x-dev » 6.x-2.x-dev
Status: Fixed » Patch (to be ported)

Let'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.

salvis’s picture

Version: 6.x-2.x-dev » 7.x-2.x-dev
Issue summary: View changes
Status: Patch (to be ported) » Closed (fixed)

Porting to D6 is not going to happen anymore, so we'll let this RIP.

salvis’s picture

Status: Closed (fixed) » Active

@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...

fenstrat’s picture

From 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.