You are here

function _support_get_attachments in Support Ticketing System 7

Same name and namespace in other branches
  1. 6 support.module \_support_get_attachments()
1 call to _support_get_attachments()
support_client_fetch in ./support.module
Fetch mail for a specific client.

File

./support.module, line 1893
support.module

Code

function _support_get_attachments($stream, $message, $structure, $parts) {
  $attachments = array();
  for ($part = 2; $part <= $parts; $part++) {
    $attachment = imap_fetchbody($stream, $message, $part);
    $details = imap_bodystruct($stream, $message, $part);

    // Decode as necessary
    if ($details->encoding == ENCBASE64) {
      $attachment = imap_base64($attachment);
    }
    else {
      if ($details->encoding == ENCQUOTEDPRINTABLE) {
        $attachment = quoted_printable_decode($attachment);
      }
      else {
        if ($details->type == TYPETEXT) {
          $attachment = imap_utf8($attachment);
        }
      }
    }
    $details->filemime = _support_get_filemime($details);
    $details->attachment = $attachment;
    $attachments[] = $details;
  }
  return $attachments;
}