When you add an attachment to an email with 'filecontent'
(instead of 'filepath'
), somewhere down the line is_file()
is checked to get the file content, because it could be a filepath. is_file()
with a full XML source is uncool, and even uncooler if open_basedir
is on, because <?xml ..... etc?>
is outside the allowed tree =)
Reproduce:
$message['params']['attachments'][] = array(
'filecontent' => $params['xml'],
'filename' => 'sehk.xml',
'filemime' => 'text/xml',
);
then at some point (in mimemail_multipart_body()
) the actual file content is retrieved:
if (isset($part['file'])) {
$file = (is_file($part['file'])) ? file_get_contents($part['file']) : $part['file'];
$part_body = chunk_split(base64_encode($file), 76, variable_get('mimemail_crlf', "\n"));
}
That is_file()
has the full XML source as argument, which upsets open_basedir
.
The solution couldn't be simpler, since @
aren't taboo in mimemail (which I like). Just add a @
:
$file = (@is_file($part['file'])) ? file_get_contents($part['file']) : $part['file'];
open_basedir
still won't like it, but is_file()
will return FALSE
and the correct file content is used. For files that are actual filepaths, nothing changes.
(Better would be if the entire mimemail flow remembers is a 'file' is a path or content, but that would require more changes, so forget I said that.)
Comments
Comment #1
rudiedirkx CreditAttribution: rudiedirkx commentedComment #2
rudiedirkx CreditAttribution: rudiedirkx commentedComment #3
sgabe CreditAttribution: sgabe commentedThis is issue is already fixed in the development snapshot. If you are having problems with a module, it is good practice to always check the development snapshot.
Comment #4
rudiedirkx CreditAttribution: rudiedirkx commentedThe 5 month old development snapshot since the last release 15 months ago? Yeah, I skipped that. Please make a new release. It's free.
Comment #5
Johnny vd Laar CreditAttribution: Johnny vd Laar at ezCompany commentedThis is the related ticket (for future references).