summaryrefslogtreecommitdiff
path: root/program
diff options
context:
space:
mode:
authortill <till@php.net>2008-02-14 01:33:02 +0000
committertill <till@php.net>2008-02-14 01:33:02 +0000
commit734584e2fe9da38246fe6c59671ef1f0c0e41859 (patch)
tree01b88e2b043a2893fc2f4fc0a86eeb241ec2a44b /program
parent50c7535072aeaa843b8ece23374057f110e43ee7 (diff)
* 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 ;-)
Diffstat (limited to 'program')
-rw-r--r--program/include/rcube_shared.inc39
-rw-r--r--program/steps/mail/sendmail.inc5
2 files changed, 42 insertions, 2 deletions
diff --git a/program/include/rcube_shared.inc b/program/include/rcube_shared.inc
index 267914736..bec254661 100644
--- a/program/include/rcube_shared.inc
+++ b/program/include/rcube_shared.inc
@@ -674,5 +674,42 @@ function strrstr($haystack, $needle)
}
}
+/**
+ * A method to guess the mime_type of an attachment.
+ *
+ * @param string $path Path to the file.
+ * @param string $failover Mime type supplied for failover.
+ *
+ * @return string
+ * @author Till Klampaeckel <till@php.net>
+ * @see http://de2.php.net/manual/en/ref.fileinfo.php
+ * @see http://de2.php.net/mime_content_type
+ */
+function rc_mime_content_type($path, $failover = 'unknown/unknown')
+{
+ global $CONFIG;
+
+ $mime_magic = $CONFIG['mime_magic'];
+
+ if (function_exists('mime_content_type')) {
+ return mime_content_type($path);
+ }
+ if (!extension_loaded('fileinfo')) {
+ if (!dl('fileinfo.' . PHP_SHLIB_SUFFIX)) {
+ return $failover;
+ }
+ }
+ $finfo = finfo_open(FILEINFO_MIME, $mime_magic);
+ if (!$finfo) {
+ return $failover;
+ }
+ $mime_type = finfo_file($finfo,$path);
+ if (!$mime_type) {
+ return $failover;
+ }
+ finfo_close($finfo);
+
+ return $mime_type;
+}
-?>
+?> \ No newline at end of file
diff --git a/program/steps/mail/sendmail.inc b/program/steps/mail/sendmail.inc
index 5a15a83ec..ede98e298 100644
--- a/program/steps/mail/sendmail.inc
+++ b/program/steps/mail/sendmail.inc
@@ -270,7 +270,10 @@ if (is_array($_SESSION['compose']['attachments']))
We need to replace mime_content_type in a later release because the function
is deprecated in favour of File_Info
*/
- $MAIL_MIME->addAttachment($attachment['path'], mime_content_type($attachment['path']), $attachment['name'], true, 'base64', 'attachment', $message_charset);
+ $MAIL_MIME->addAttachment($attachment['path'],
+ rc_mime_content_type($attachment['path'], $attachment['mimetype']),
+ $attachment['name'], true, 'base64',
+ 'attachment', $message_charset);
}
}