public static function PHPMailer::_mime_types

5.x PHPMailer.php public static PHPMailer::_mime_types($ext = '')

Get the MIME type for a file extension.

Parameters

string $ext File extension:

Return value

string MIME type of file

2 calls to PHPMailer::_mime_types()
PHPMailer::filenameToType in inc/PHPMailer/src/PHPMailer.php
Map a file name to a MIME type. Defaults to 'application/octet-stream', i.e.. arbitrary binary data.
PHPMailer::msgHTML in inc/PHPMailer/src/PHPMailer.php
Create a message body from an HTML string. Automatically inlines images and creates a plain-text version by converting the HTML, overwriting any existing values in Body and AltBody. Do not source $message content from user input! $basedir is prepended…

File

inc/PHPMailer/src/PHPMailer.php, line 3991

Class

PHPMailer
PHPMailer - PHP email creation and transport class.

Namespace

PHPMailer\PHPMailer

Code

public static function _mime_types($ext = '') 
 {
  $mimes = [
    'xl' => 'application/excel',
    'js' => 'application/javascript',
    'hqx' => 'application/mac-binhex40',
    'cpt' => 'application/mac-compactpro',
    'bin' => 'application/macbinary',
    'doc' => 'application/msword',
    'word' => 'application/msword',
    'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
    'xltx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.template',
    'potx' => 'application/vnd.openxmlformats-officedocument.presentationml.template',
    'ppsx' => 'application/vnd.openxmlformats-officedocument.presentationml.slideshow',
    'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
    'sldx' => 'application/vnd.openxmlformats-officedocument.presentationml.slide',
    'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
    'dotx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.template',
    'xlam' => 'application/vnd.ms-excel.addin.macroEnabled.12',
    'xlsb' => 'application/vnd.ms-excel.sheet.binary.macroEnabled.12',
    'class' => 'application/octet-stream',
    'dll' => 'application/octet-stream',
    'dms' => 'application/octet-stream',
    'exe' => 'application/octet-stream',
    'lha' => 'application/octet-stream',
    'lzh' => 'application/octet-stream',
    'psd' => 'application/octet-stream',
    'sea' => 'application/octet-stream',
    'so' => 'application/octet-stream',
    'oda' => 'application/oda',
    'pdf' => 'application/pdf',
    'ai' => 'application/postscript',
    'eps' => 'application/postscript',
    'ps' => 'application/postscript',
    'smi' => 'application/smil',
    'smil' => 'application/smil',
    'mif' => 'application/vnd.mif',
    'xls' => 'application/vnd.ms-excel',
    'ppt' => 'application/vnd.ms-powerpoint',
    'wbxml' => 'application/vnd.wap.wbxml',
    'wmlc' => 'application/vnd.wap.wmlc',
    'dcr' => 'application/x-director',
    'dir' => 'application/x-director',
    'dxr' => 'application/x-director',
    'dvi' => 'application/x-dvi',
    'gtar' => 'application/x-gtar',
    'php3' => 'application/x-httpd-php',
    'php4' => 'application/x-httpd-php',
    'php' => 'application/x-httpd-php',
    'phtml' => 'application/x-httpd-php',
    'phps' => 'application/x-httpd-php-source',
    'swf' => 'application/x-shockwave-flash',
    'sit' => 'application/x-stuffit',
    'tar' => 'application/x-tar',
    'tgz' => 'application/x-tar',
    'xht' => 'application/xhtml+xml',
    'xhtml' => 'application/xhtml+xml',
    'zip' => 'application/zip',
    'mid' => 'audio/midi',
    'midi' => 'audio/midi',
    'mp2' => 'audio/mpeg',
    'mp3' => 'audio/mpeg',
    'm4a' => 'audio/mp4',
    'mpga' => 'audio/mpeg',
    'aif' => 'audio/x-aiff',
    'aifc' => 'audio/x-aiff',
    'aiff' => 'audio/x-aiff',
    'ram' => 'audio/x-pn-realaudio',
    'rm' => 'audio/x-pn-realaudio',
    'rpm' => 'audio/x-pn-realaudio-plugin',
    'ra' => 'audio/x-realaudio',
    'wav' => 'audio/x-wav',
    'mka' => 'audio/x-matroska',
    'bmp' => 'image/bmp',
    'gif' => 'image/gif',
    'jpeg' => 'image/jpeg',
    'jpe' => 'image/jpeg',
    'jpg' => 'image/jpeg',
    'png' => 'image/png',
    'tiff' => 'image/tiff',
    'tif' => 'image/tiff',
    'webp' => 'image/webp',
    'heif' => 'image/heif',
    'heifs' => 'image/heif-sequence',
    'heic' => 'image/heic',
    'heics' => 'image/heic-sequence',
    'eml' => 'message/rfc822',
    'css' => 'text/css',
    'html' => 'text/html',
    'htm' => 'text/html',
    'shtml' => 'text/html',
    'log' => 'text/plain',
    'text' => 'text/plain',
    'txt' => 'text/plain',
    'rtx' => 'text/richtext',
    'rtf' => 'text/rtf',
    'vcf' => 'text/vcard',
    'vcard' => 'text/vcard',
    'ics' => 'text/calendar',
    'xml' => 'text/xml',
    'xsl' => 'text/xml',
    'wmv' => 'video/x-ms-wmv',
    'mpeg' => 'video/mpeg',
    'mpe' => 'video/mpeg',
    'mpg' => 'video/mpeg',
    'mp4' => 'video/mp4',
    'm4v' => 'video/mp4',
    'mov' => 'video/quicktime',
    'qt' => 'video/quicktime',
    'rv' => 'video/vnd.rn-realvideo',
    'avi' => 'video/x-msvideo',
    'movie' => 'video/x-sgi-movie',
    'webm' => 'video/webm',
    'mkv' => 'video/x-matroska',
  ];
  $ext = strtolower($ext);
  if (array_key_exists($ext, $mimes)) {
    return $mimes [$ext];
  }

  return 'application/octet-stream';
}