You are here

class MailhandlerCommandsFiles in Mailhandler 6.2

Same name and namespace in other branches
  1. 7.2 plugins/mailhandler/commands/MailhandlerCommandsFiles.class.php \MailhandlerCommandsFiles

@file MailhandlerCommandsFiles class.

Hierarchy

Expanded class hierarchy of MailhandlerCommandsFiles

2 string references to 'MailhandlerCommandsFiles'
MailhandlerCommandsFiles.inc in plugins/mailhandler/commands/MailhandlerCommandsFiles.inc
mailhandler_update_6202 in ./mailhandler.install
Adds new command plugins to existing Feeds importers.

File

plugins/mailhandler/commands/MailhandlerCommandsFiles.class.php, line 7
MailhandlerCommandsFiles class.

View source
class MailhandlerCommandsFiles extends MailhandlerCommands {

  /**
   * Parse attachments from message mimeparts.
   */
  function process(&$message, $source) {
    $message['attachments'] = array();
    foreach ($message['mimeparts'] as $attachment) {

      // 'unnamed_attachment' files are not really attachments, but mimeparts like HTML or Plain Text.
      // We only want to save real attachments, like images and files.
      if ($attachment->filename !== 'unnamed_attachment') {
        $filename = mb_decode_mimeheader($attachment->filename);
        $file = file_save_data($attachment->data, file_directory_temp() . '/' . mb_decode_mimeheader($filename));
        $cid = NULL;
        if (!empty($attachment->id)) {
          $cid = trim($attachment->id, '<>');
        }
        $message['attachments'][] = new MailhandlerAttachmentEnclosure($filename, $attachment->filemime, $attachment->data, $cid);
      }
    }
    unset($message['mimeparts']);
  }
  function getMappingSources($config) {
    $sources = array();
    $sources['attachments'] = array(
      'title' => t('Attachments'),
      'description' => t('Files attached to message.'),
    );
    return $sources;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
MailhandlerCommands::$commands protected property
MailhandlerCommands::configForm public function Build configuration form. 2
MailhandlerCommands::parse public function Parse commands from email body. 1
MailhandlerCommands::sourceForm public function Build source form. 1
MailhandlerCommandsFiles::getMappingSources function Return mapping sources in the same manner as a Feeds Parser. Overrides MailhandlerCommands::getMappingSources
MailhandlerCommandsFiles::process function Parse attachments from message mimeparts. Overrides MailhandlerCommands::process