Permalink
Browse files

Added automatic setting of attachment size via Content-Disposition si…

…ze parameter
  • Loading branch information...
alecpl committed Jun 9, 2012
1 parent ad596b0 commit 2202d28f025a3ef13105e69d334b3580000ae433
View
@@ -247,6 +247,12 @@ function Mail_mimePart($body = '', $params = array())
!empty($params['filename_encoding']) ? $params['filename_encoding'] : null
);
}
+
+ // add attachment size
+ $size = $this->_body_file ? filesize($this->_body_file) : strlen($body);
+ if ($size) {
+ $headers['Content-Disposition'] .= ';' . $this->_eol . ' size=' . $size;
+ }
}
if (!empty($params['description'])) {
View
@@ -41,6 +41,7 @@ using RFC2047 and/or RFC2231.</description>
<license uri="http://www.opensource.org/licenses/bsd-license.php">BSD Style</license>
<notes>
* Added possibility to set additional parameters of message part header, e.g. attachment size [alec]
+ * Added automatic setting of attachment size via Content-Disposition header size parameter [alec]
</notes>
<contents>
<dir name="/">
@@ -24,4 +24,5 @@ echo $enc->_headers['Content-Disposition'];
text/plain; charset=ISO-8859-1;
name="=?ISO-8859-1?Q?=C5=9Bciema?="
attachment;
- filename="=?ISO-8859-1?B?xZtjaWVtYQ==?="
+ filename="=?ISO-8859-1?B?xZtjaWVtYQ==?=";
+ size=8
@@ -15,4 +15,5 @@ print_r($enc->_headers['Content-Disposition']);
?>
--EXPECT--
attachment;
- filename*=ISO-8859-1''%C5%9Bciema
+ filename*=ISO-8859-1''%C5%9Bciema;
+ size=8
@@ -22,4 +22,5 @@ echo $enc->_headers['Content-Disposition'];
text/plain; charset=ISO-8859-1;
name="=?UTF-8?Q?=C5=9Bciema?="
attachment;
- filename="=?UTF-8?B?xZtjaWVtYQ==?="
+ filename="=?UTF-8?B?xZtjaWVtYQ==?=";
+ size=8
@@ -12,4 +12,5 @@ $enc = $Mime->_addAttachmentPart($root, $Mime->_parts[0]);
print($enc->_headers['Content-Disposition']);
--EXPECT--
attachment;
- filename*=ISO-8859-1''F%F3%F3b%E6r.txt
+ filename*=ISO-8859-1''F%F3%F3b%E6r.txt;
+ size=8
@@ -13,4 +13,5 @@ print($enc->_headers['Content-Disposition']);
--EXPECT--
attachment;
filename*0*=UTF-8'de'S%C3%BCper%20gr%C3%B6se%20tolle%20tolle%20gr%C3%BC;
- filename*1*=%C3%9Fe.txt
+ filename*1*=%C3%9Fe.txt;
+ size=8
@@ -15,4 +15,6 @@ print($enc->_headers['Content-Disposition']);
?>
--EXPECT--
attachment;
- filename*=iso-2022-jp''%1B$BF|K%5C8l%1B%28B.txt
+ filename*=iso-2022-jp''%1B$BF|K%5C8l%1B%28B.txt;
+ size=8
+

0 comments on commit 2202d28

Please sign in to comment.