I made a simple test mail with images, which I send using the HTML Mail Send Test option.
If I send these tests, the resulting mail has a text-version as well. That is good: at least part of Mail MIME is working correctly.
But the image links are not changed in any way. The links are in the received mail exactly as I wrote them in the test file.
I have HTML Mail (6.x-2.60) installed with Mail MIME (6.x-2.15)
The pear files needed by Mail MIME are located in /usr/share/php and /usr/share/php/Mail (the docs are not clear about this, but I assume this is correct ?). There are no error messages about these files.
If I type 'env' at the commandline then it does not show a 'include_path' variable. I am not sure if that is a problem ? I also do not know how to define such a variable in such a way that Drupal finds it (even after system restarts) ?
This is (part of) my test mail body:
<!-- some local file -->
<img src="file:////home/quickstart/websites/sjnab.nl/sites/all/myfiles/auto.jpg" alt="Angry face" width="32" height="32" />
<!-- some remote file -->
<img src="http://www.pdssb.com.my/images/stories/gallery/laptop.jpg" alt="laptop" />
Maybe I do not understand how this works ? I expected something in the line of http://en.wikipedia.org/wiki/Data_URI_scheme
Or do I have to format the links in some special way ? I cannot find any sample file or documentation about the actual use.
Comments
Comment #1
pillarsdotnet commentedFrom the PHP manual:
require(),include(),fopen(),file(),readfile()andfile_get_contents()functions look for files. The format is like the system'sPATHenvironment variable: a list of directories separated with a colon in Unix or semicolon in Windows.Mail MIME does not convert
file:///links; sorry.Nor does it resolve references to external websites. It only converts image links that are located within the same domain that is sending mail, and which resolve to Drupal files.
The relevant code snippet is found in
mailmime.inc:So if:
then the file is attached.
Even if the Drupal installation that is sending mail is located at www.pdssb.com.my, I'm not sure that the second link would be converted, because "images/stories/gallery/laptop.jpg" does not look like a Drupal file path.
I suppose it would be possible for MailMIME to attempt to resolve and download other (non-local, non-Drupal) image links and attach them, but I would have to carefully consider the impact on performance, security, and file management.
Comment #2
pillarsdotnet commentedChanging to a feature request.
Comment #3
l_o_l commentedAt least on my system (Ubuntu) there seems no need for the include_path var.
Al it needed was an acceptable image link:
This includes an image from a custom path inside the normal Drupal dir tree (I read somewhere that the default/files folder is best to keep fully managed by Drupal and untouched by anything else).
I suggest you add the limitations and a sample like above to the MailMIME readme.
O, and the exact functionality of the Mail MIME module is better explained in the text for Html Mail :-) Therefore you might also add 'Provides a text/plain alternative to text/html emails, and automatically converts image references to inline image attachments' to the text for Mail MIME itself.
I completely agree with the security implications of including images from other websites. One more elaborate solution: the admin can allow images from only certain domains.
Comment #4
cedric commentedWe are embedding image styles (auto-generated thumbnails) in emails.
When sending the email, the image does not exist on the filesystem. It is generated by drupal on first request.
Mail MIME tries to resolve the path of images to local filesystem, but does not find the image. The image does not get embedded.
We would like to see Mail MIME perform an HTTP get request to download and embed the image, that would be much more reliable, and would avoid all the url to path non-sense that attempts to do the job of the web server.
Comment #5
salvis@cedric:
It's unlikely that we can mount the effort required for investigating, implementing, testing, and reviewing this.
Can you not trigger the generation of the thumbnails in whatever module is using Mail MIME to create the emails?