I am using simplenews with mimemail. I have implemented mail.css which has been placed in the main directory of the zen sub-template. I have copied the template from simplenews and modified it and it appears that it is being read, as the content comes out in the mail that arrives. The problem is that the image arrives but not as a CID number as one would expect (embedded) but as a web address (which is how it is included in the template).

<img style="float:left" src="http://www.sitename.co.za/sites/default/files/lsc3.jpg" width="150" alt="" border="0">

Possibly I have missed something in the documentation, regarding this line but it would appear that mimemail is not embedding it.

I'd be grateful for assistance!

Comments

sgabe’s picture

Did you read the README.txt?

sgabe’s picture

Status: Active » Fixed

Images with absolute URL will be available as remote content. To embed images into emails you have to use a relative URL or an internal path.

For example:
instead of http://www.mysite.com/sites/default/files/mypicture.jpg
use /home/www/public_html/drupal/sites/default/files/mypicture.jpg
or /sites/default/files/mypicture.jpg

hbblogger’s picture

Hi,

Thanks for your response. In fact I did read the readme.txt .

I have tried each of the options suggested (although for the second one I used /home2/mydomain/public_html/mysite.co.za/sites/all/default/files/mypicture.jpg)

I have placed this code in mimemail-message.tpl.php and placed this in the root folder of my zen subtheme (having first changed my admin to the zen subtheme) and confirmed using a message that this is in fact the file being displayed.

I have also placed a similar piece of code in the simplenews-newsletter-body.tpl.php file which was placed in the template folder of my zen subtheme. This also displays but still no image.

I send my e-mails to both outlook 2003 and to g-mail.

hbblogger’s picture

For completeness, I have just tried /home/www/.......

sgabe’s picture

Status: Fixed » Active

This is a huge misunderstanding. You can embed images only in the body of the message, not in the template files. Let's clear this up in the README.txt file.

hbblogger’s picture

Thats a real pity as the template is really where you need to be able to add images (such as logos) to keep the look and feel the same. Thanks for letting me know, though. If that ever changes - I'd be keen to hear about it.

sgabe’s picture

Title: embedding images » Embed images in template

Well, this issue can be either a feature request or a task to update the documentation with this information.

hbblogger’s picture

Category: support » feature

I hereby request that a feature be added to the Mime Mail module to enable the use of templates that include embedded images.

hbblogger’s picture

Category: feature » task

I hereby suggest that until a feature is available in the Mime Mail module to embed images in the template, that the exisiting readme.txt file be updated to indicate that images embedded in the template will not be converted by Mime Mail and thus will not be displayed in the recipients e-mail message.

sgabe’s picture

Category: task » support
Status: Active » Closed (works as designed)

I have just tested this and it is working with both branches. If the path is a correct relative path the image will be embedded in the message.

bshensky’s picture

Confirmed #10 - embedding of an image inside the template file does indeed work. Do not put the leading slash ahead of the asset hanging off the base_path.

<div id="mimemail-header">
  <img src="themes/garland/logo.png" alt="Logo Goes Here" id="logo" />
</div>

Glad that this works!

finne’s picture

When you use a private filesystem in D6 you cannot embed images from your theme folder (such as the logo). To achieve this copy the logo to somewhere inside your private file path, so the mime mail access check allow embedding. I used

<img src="<?php print base_path(); ?>sites/default/files/theme/logo.png" alt="logo" />

Setting the privilege 'send arbitrary files' did not work either because the simplenews module I use sends messages as the anonymous user (thus the access check fails or I should allow this privilege for the anon user)

finne’s picture

Issue summary: View changes

Modified my code so that it reflected code not image.

bnorbi’s picture

#12 worked for me in D6.

mibfire’s picture

Issue summary: View changes

Does this work only with images in files folder like "sites/default/files/mypicture.jpg"? Cos i havent been able to embed image using my theme directory like "sites/all/themes/mytheme/images/logo2.png".

gusantor’s picture

In mytheme/mimemail-message.tpl.php I have

<img  src="<?php echo "sites/default/files/isotipo.gif"; ?>">
<img  src="<?php echo "sites/all/themes/mythme/images/isotipo.gif"; ?>">
<img  src="<?php echo file_stream_wrapper_get_instance_by_uri('public://')->realpath()."/isotipo.gif"; ?>">

when I'm logged as Administrator I receive a nice email with three images, but logged as some other registered user, email with no images at all

some idea how to get all user have images on email ?

mdruilhe’s picture

Category: Support request » Bug report
Status: Closed (works as designed) » Needs work

I have the same problem using simplenews with D7 and mimemail 7.x-1.0-beta3
In my template, if I put :
<img src="<?php echo base_path()?>sites/all/themes/mytheme/img/newsletter/logo.png" alt="Logo" />
or
<img src="sites/all/themes/mytheme/img/newsletter/logo.png" alt="Logo" />

The images aren't displayed in the mail, even logged in as admin.

It works fine with mimemail 7.x-1.0-alpha2 :both images are showing in the mail.

I guess the problem is in _mimemail_file() (mimemail.inc) but I don't know how to solve it.

Please, any thought ?
Thanks in advance for your help

rbosscher’s picture

I've had the same problem, after investigating the issue, I came to line 190 in mimemail.inc

  if (isset($file) && (@is_file($file) || $content)) {
    $public_path = file_default_scheme() . '://';
    $no_access = !user_access('send arbitrary files');
    $not_in_public_path = strpos(drupal_realpath($file), drupal_realpath($public_path)) !== 0;
    if (@is_file($file) && $not_in_public_path && $no_access) {
      return $url;
    }

This piece of code only allows files from your public files folder.
So no theme images are possible in your mimemail-message.tpl.php.

Strange enough, this is only the case when I try sending with simplenews.
Other modules will send out the theme files just fine.

dualcorpse’s picture

It actually worked for me using $GLOBALS['base_url'] (as anonymous user) :

<img src="<?php echo $GLOBALS['base_url']; ?>/sites/all/themes/my_theme/logo.png" />