function _mimemail_mimetype in Mime Mail 5
Attempt to determine the mimetime from or filename . While not ideal, using the filename as a fallback ensures that images will appear inline in HTML messages
Parameters
$name Name of the file:
Return value
best-guess mimetype string
2 calls to _mimemail_mimetype()
- mimemail_multipart_body in ./
mimemail.inc - _mimemail_file in ./
mimemail.inc - Helper function to extract local files
File
- ./
mimemail.inc, line 541
Code
function _mimemail_mimetype($file, $type = '') {
if ($type) {
return $type;
}
if (function_exists('mime_content_type')) {
return mime_content_type($file);
}
// some common embedded/attachment types
$types = array(
'jpg' => 'image/jpeg',
'jpeg' => 'image/jpeg',
'gif' => 'image/gif',
'png' => 'image/png',
);
$ext = strtolower(substr(strrchr($file, '.'), 1));
if (isset($types[$ext])) {
return $types[$ext];
}
return 'application/octet-stream';
}