*** mimemail_old.inc	2009-02-24 03:11:19.000000000 +1100
--- mimemail.inc	2010-01-30 18:51:35.000000000 +1100
***************
*** 108,114 ****
   */
  function _mimemail_file($url = NULL, $name = '', $type = '', $disposition = 'related') {
    static $files = array();
-   static $filenames = array();
  
    if ($url) {
      $url = _mimemail_url($url, 'TRUE');
--- 108,113 ----
***************
*** 123,148 ****
      }
    }
  
!   if ($file && file_exists($file)) {
!     // Prevent duplicate items
!     if (isset($filenames[$file])) return 'cid:'. $filenames[$file];
!     
!     $content_id = md5($file) .'@'. $_SERVER['HTTP_HOST'];
! 
!     if (!$name) $name = substr($file, strrpos($file, '/') + 1);
! 
!     $new_file = array(
!       'name' => $name,
!       'file' => $file,
!       'Content-ID' => $content_id,
!       'Content-Disposition' => $disposition,
!     );
!     $new_file['Content-Type'] = file_get_mimetype($file);
  
!     $files[] = $new_file;
!     $filenames[$file] = $content_id;
  
!     return 'cid:'. $content_id;
    }
  
    $ret = $files;
--- 122,147 ----
      }
    }
  
!   if ($file) {
!     if (!file_exists($file)) {
!       return $url;                       // this part has changed
!     } else {
!       $content_id = md5($file) .'@'. $_SERVER['HTTP_HOST'];
! 
!       if (!$name) $name = substr($file, strrpos($file, '/') + 1);
! 
!       $new_file = array(
!         'name' => $name,
!         'file' => $file,
!         'Content-ID' => $content_id,
!         'Content-Disposition' => $disposition,
!       );
!       $new_file['Content-Type'] = _mimemail_mimetype($file, $type);
  
!       $files[] = $new_file;
  
!       return 'cid:'. $content_id;
!     }
    }
  
    $ret = $files;
