You are here

function MailhandlerPhpImapRetrieve::get_mime_type in Mailhandler 6.2

Same name and namespace in other branches
  1. 7.2 modules/mailhandler_php_imap/plugins/mailhandler/retrieve/MailhandlerPhpImapRetrieve.class.php \MailhandlerPhpImapRetrieve::get_mime_type()

Retrieve MIME type of the message structure.

1 call to MailhandlerPhpImapRetrieve::get_mime_type()
MailhandlerPhpImapRetrieve::get_part in modules/mailhandler_php_imap/plugins/mailhandler/retrieve/MailhandlerPhpImapRetrieve.class.php
Gets a message part and adds it to $parts.

File

modules/mailhandler_php_imap/plugins/mailhandler/retrieve/MailhandlerPhpImapRetrieve.class.php, line 310
Definition of MailhandlerPhpImapRetrieve class.

Class

MailhandlerPhpImapRetrieve
Retrieve messages using PHP IMAP library.

Code

function get_mime_type(&$structure) {
  static $primary_mime_type = array(
    'text',
    'multipart',
    'message',
    'application',
    'audio',
    'image',
    'video',
    'other',
  );
  $type_id = (int) $structure->type;
  if (isset($primary_mime_type[$type_id]) && !empty($structure->subtype)) {
    return $primary_mime_type[$type_id] . '/' . drupal_strtolower($structure->subtype);
  }
  return 'text/plain';
}