Tools\Mailer\Email::_getMime PHP Method

_getMime() protected method

Try to find mimetype by file extension
protected _getMime ( string $filename, string $default = 'application/octet-stream' ) : string
$filename string File name
$default string default MimeType
return string Mimetype (falls back to `application/octet-stream`)
    protected function _getMime($filename, $default = 'application/octet-stream')
    {
        if (!isset($this->_Mime)) {
            $this->_Mime = new Mime();
        }
        $mime = $this->_Mime->detectMimeType($filename);
        // Some environments falsely return the default too fast, better fallback to extension here
        if (!$mime || $mime === $default) {
            $ext = pathinfo($filename, PATHINFO_EXTENSION);
            $mime = $this->_Mime->getMimeTypeByAlias($ext);
        }
        return $mime;
    }