If you set the variable to convert embedded images into links (variable mimemail_linkonly), then you can't attach image files - any image files added as attachments silently disappear.

I have solved the problem for myself by adding

if ($disposition == 'attachment') $linkonly = 0;

after line 167 of mimemail.inc, so that the start of _mimemail_file now reads:

function _mimemail_file($url = NULL, $content = NULL, $name = '', $type = '', $disposition = 'inline') {
  static $files = array();
  static $ids = array();

  if ($url) {
    $image = preg_match('!\.(png|gif|jpg|jpeg)$!i', $url);
    $linkonly = variable_get('mimemail_linkonly', 0);
    if ($disposition == 'attachment') $linkonly = 0;
    // The file exists on the server as-is. Allows for non-web-accessible files.

I am not aware of the wider ramifications of that change.

Comments

ogursoy’s picture

Bug and the solution above confirmed.

TR’s picture

Version: 7.x-1.0-beta3 » 7.x-1.x-dev
Issue tags: -image attachments, -embedded images
TR’s picture

Issue tags: +Needs tests

See also the discussion in #2183955: Private File System and image not being embedded - Could someone advice me. comments #19, #20, #21, #22, and #23, where this issue was raised and a fix similar to the above was also provided.

This issue needs a PATCH and a TEST that demonstrates the bug and proves the fix.