In working with the latest DEV version. The function _mimemail_file has been changed/updated to only pass through images when sending an absolute path to the $url parameter.
In file mimemail.inc on line 156.
I have updated the code as such:
if ($url) {
// The file exists on the server as-is. Allows for non-web-accessible files.
if (@is_file($url)) {
$file = $url;
}
else {
$image = preg_match('!\.(png|gif|jpg|jpeg)$!i', $url);
$linkonly = variable_get('mimemail_linkonly', 0);
// The file exists on the server as-is. Allows for non-web-accessible files.
if (@is_file($url) && $image && !$linkonly) {
$file = $url;
}
else {
$url = _mimemail_url($url, 'TRUE');
// The $url is absolute, we're done here.
$scheme = file_uri_scheme($url);
if ($scheme == 'http' || $scheme == 'https' || preg_match('!mailto:!', $url)) {
return $url;
}
// The $url is a non-local URI that needs to be converted to a URL.
else {
$file = (drupal_realpath($url)) ? drupal_realpath($url) : file_create_url($url);
}
}
}
}
It was:
if ($url) {
$image = preg_match('!\.(png|gif|jpg|jpeg)$!i', $url);
$linkonly = variable_get('mimemail_linkonly', 0);
// The file exists on the server as-is. Allows for non-web-accessible files.
if (@is_file($url) && $image && !$linkonly) {
$file = $url;
}
else {
$url = _mimemail_url($url, 'TRUE');
// The $url is absolute, we're done here.
$scheme = file_uri_scheme($url);
if ($scheme == 'http' || $scheme == 'https' || preg_match('!mailto:!', $url)) {
return $url;
}
// The $url is a non-local URI that needs to be converted to a URL.
else {
$file = (drupal_realpath($url)) ? drupal_realpath($url) : file_create_url($url);
}
}
}
I can supply a patch if this is the way you want it to be handled. Not sure why you changed it originally so I don't want to assume anything. I am sending out PDF attachements so this hindered my progress.
But instead of changing the code as in above, I have altered my rule to not send the absolute path and instead send the uri. It will pick up my PDF that way. I just think there needs to be some standard way of sending files to this function. Seems overly complicated to me, but again I don't want to assume on the why part.
So my adding attachements through rules went from:
echo drupal_realpath(file_load($file['fid'])->uri);
to:
echo file_load($file['fid'])->uri;
Comments
Comment #1
iLLin commentedComment #1.0
iLLin commentedupdating description to be a bit more clear.
Comment #2
tr commentedYou didn't supply a patch, so it's not obvious exactly what you changed, but it appears to me you reverted the changes made in #1439918: "Link images only" is not working if the file exists as-is. That breaks the fix put in by that patch.
Regardless, it has been 10 years and nobody responded. I don't know of any current problems attaching PDF files.
If this is still a problem in the current version of Mime Mail, please open a new issue and provide instructions for reproducing the problem.