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

rudiedirkx’s picture

Title: Warning with open_basedir and dynamic/content attachments » Warning with is_file(), open_basedir and dynamic/content attachments
Issue summary: View changes
rudiedirkx’s picture

Issue summary: View changes
sgabe’s picture

Status: Active » Closed (duplicate)

This 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.

rudiedirkx’s picture

The 5 month old development snapshot since the last release 15 months ago? Yeah, I skipped that. Please make a new release. It's free.

Johnny vd Laar’s picture

This is the related ticket (for future references).