Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Request #19406: Allow to set individual attachment part headers

  • Loading branch information...
commit fbe36e840a2d9c0165995bb2d6a2b53a004ebeae 1 parent 928429b
@alecpl alecpl authored
Showing with 13 additions and 1 deletion.
  1. +7 −1 Mail/Mime2.php
  2. +6 −0 Mail/MimePart2.php
View
8 Mail/Mime2.php
@@ -386,6 +386,7 @@ public function addHTMLImage($file,
* @param string $description Content-Description header
* @param string $h_charset The character set of the headers e.g. filename
* If not specified, $charset will be used
+ * @param array $add_headers Additional part headers
*
* @return mixed True on success or PEAR_Error object
* @access public
@@ -402,7 +403,8 @@ public function addAttachment($file,
$n_encoding = null,
$f_encoding = null,
$description = '',
- $h_charset = null
+ $h_charset = null,
+ $add_headers = array()
) {
$bodyfile = null;
@@ -441,6 +443,7 @@ public function addAttachment($file,
'location' => $location,
'disposition' => $disposition,
'description' => $description,
+ 'add_headers' => $add_headers,
'name_encoding' => $n_encoding,
'filename_encoding' => $f_encoding,
'headers_charset' => $h_charset,
@@ -679,6 +682,9 @@ private function _addAttachmentPart($obj, $value)
if (!empty($value['description'])) {
$params['description'] = $value['description'];
}
+ if (is_array($value['add_headers'])) {
+ $params['headers'] = $value['add_headers'];
+ }
$ret = $obj->addSubpart($value['body'], $params);
return $ret;
View
6 Mail/MimePart2.php
@@ -156,6 +156,7 @@ class Mail_MimePart2
* headers_charset - Charset of the headers e.g. filename, description.
* If not set, 'charset' will be used
* eol - End of line sequence. Default: "\r\n"
+ * headers - Hash array with additional part headers
* body_file - Location of file with part's body (instead of $body)
*/
public function __construct($body = '', $params = array())
@@ -164,6 +165,11 @@ public function __construct($body = '', $params = array())
$this->_eol = $params['eol'];
}
+ // Additional part headers
+ if (!empty($params['headers']) && is_array($params['headers'])) {
+ $headers = $params['headers'];
+ }
+
foreach ($params as $key => $value) {
switch ($key) {
case 'encoding':
Please sign in to comment.
Something went wrong with that request. Please try again.