Changeset 734584e in github


Ignore:
Timestamp:
Feb 13, 2008 8:33:02 PM (5 years ago)
Author:
till <till@…>
Branches:
master, HEAD, courier-fix, dev-browser-capabilities, pdo, release-0.6, release-0.7, release-0.8
Children:
d722de1
Parents:
50c7535
Message:
  • mime_content_type() is unavailable in PHP5 and breaks sending emails with attachments
  • implemented rc_mime_content_type() with file_info-failover
  • added svn:ignore for phpinfo.php ;-)
Location:
program
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • program/include/rcube_shared.inc

    r6f99263 r734584e  
    675675} 
    676676 
     677/** 
     678 * A method to guess the mime_type of an attachment. 
     679 * 
     680 * @param string $path     Path to the file. 
     681 * @param string $failover Mime type supplied for failover. 
     682 * 
     683 * @return string 
     684 * @author Till Klampaeckel <till@php.net> 
     685 * @see    http://de2.php.net/manual/en/ref.fileinfo.php 
     686 * @see    http://de2.php.net/mime_content_type 
     687 */ 
     688function rc_mime_content_type($path, $failover = 'unknown/unknown') 
     689{ 
     690    global $CONFIG; 
     691 
     692    $mime_magic = $CONFIG['mime_magic']; 
     693 
     694    if (function_exists('mime_content_type')) { 
     695        return mime_content_type($path); 
     696    } 
     697    if (!extension_loaded('fileinfo')) {  
     698        if (!dl('fileinfo.' . PHP_SHLIB_SUFFIX)) { 
     699            return $failover; 
     700        } 
     701    } 
     702    $finfo = finfo_open(FILEINFO_MIME, $mime_magic); 
     703    if (!$finfo) { 
     704        return $failover; 
     705    } 
     706    $mime_type = finfo_file($finfo,$path); 
     707    if (!$mime_type) { 
     708        return $failover; 
     709    } 
     710    finfo_close($finfo); 
     711 
     712    return $mime_type; 
     713} 
    677714 
    678715?> 
  • program/steps/mail/sendmail.inc

    r75f0a73 r734584e  
    271271        is deprecated in favour of File_Info 
    272272      */ 
    273       $MAIL_MIME->addAttachment($attachment['path'], mime_content_type($attachment['path']), $attachment['name'], true, 'base64', 'attachment', $message_charset); 
     273      $MAIL_MIME->addAttachment($attachment['path'], 
     274        rc_mime_content_type($attachment['path'], $attachment['mimetype']), 
     275        $attachment['name'], true, 'base64', 
     276        'attachment', $message_charset); 
    274277    } 
    275278  } 
Note: See TracChangeset for help on using the changeset viewer.