You are here

class MailhandlerCommandsFiles in Mailhandler 7.2

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

Provides file attachments.

Hierarchy

Expanded class hierarchy of MailhandlerCommandsFiles

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

File

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

View source
class MailhandlerCommandsFiles extends MailhandlerCommands {

  /**
   * Parse attachments from message mimeparts.
   */
  public 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);
        $cid = NULL;
        if (!empty($attachment->id)) {
          $cid = trim($attachment->id, '<>');
        }
        $message['attachments'][] = new MailhandlerAttachmentEnclosure($filename, $attachment->filemime, $attachment->data, $cid);
      }
    }
    unset($message['mimeparts']);
  }

  /**
   * Implements getMappingSources().
   */
  public 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 public function Implements getMappingSources(). Overrides MailhandlerCommands::getMappingSources
MailhandlerCommandsFiles::process public function Parse attachments from message mimeparts. Overrides MailhandlerCommands::process