When file access mode in Drupal settings is set to 'private' and image src is 'system/files?file=image.jpg', it's not included in the mail (no section in the multipart).

Comments

miopa’s picture

Title: Not including 'private' images in the mail » Fix

This works for me, should be Ok

In mimemail.inc function _mimemail_file should look like this:


function _mimemail_file($file = NULL, $type = '') {
  static $files = array();

  if ($file && !preg_match('@://|mailto:@', $file)) {
  	if (strpos($file, 'system/files?file=') !== false)
		$file = file_create_path(substr($file, strlen('system/files?file=')));
  	if (file_exists($file)) {
	    $content_id = md5($file) .'@'. $_SERVER['HTTP_HOST'];
		$name = (strrpos($file, '/') === false ? $file : substr($file, strrpos($file, '/') + 1)); 
	    $new_file = array('name' => $name,
	                      'file' => $file,
	                      'Content-ID' => $content_id,
	                      'Content-Disposition' => 'related',
	                     );
	    $new_file['Content-Type'] = _mimemail_mimetype($file,$type);
	
	    $files[] = $new_file;
	
	    return 'cid:'. $content_id;
  	}
  }
  
  if ($file) {
    return $file;
  }
  
  return $files;
}
miopa’s picture

Title: Fix » Not including 'private' images in the mail
allie micka’s picture

Please submit a patch so we can clearly see your changes and effect them without mucking things up.

We can't use a hard-coded value for 'system/files?file=' . I believe that the files directory is parameterized, so that parameter must be used.

Also, I would prefer to respect the setting for private files instead of trying to derive the setting by groking the url.

If you can submit a working patch that respects these two variables, I will apply it. Otherwise, I will get to this when I can.

Thanks!

jerdavis’s picture

Priority: Normal » Minor
Status: Active » Postponed (maintainer needs more info)

Setting this one to minor - if you can provide a patch cleaned up as requested above we can get this in a lot faster!

allie micka’s picture

Status: Postponed (maintainer needs more info) » Closed (won't fix)

I'm marking this as won't fix, as it's gone for over 2 1/2 years without any feedback or followup.