From 6f82ed1e4005f034a1d9443e896d64726735c16f Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Sat, 14 Nov 2009 19:57:50 -0700 Subject: [PATCH] Request #8556: Allow specifying a header charset for a part --- framework/Mime/lib/Horde/Mime/Part.php | 33 +++++++++++++++++++++++++++++++-- framework/Mime/package.xml | 3 ++- 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/framework/Mime/lib/Horde/Mime/Part.php b/framework/Mime/lib/Horde/Mime/Part.php index 1ac91e278..830cfd65f 100644 --- a/framework/Mime/lib/Horde/Mime/Part.php +++ b/framework/Mime/lib/Horde/Mime/Part.php @@ -201,6 +201,13 @@ class Horde_Mime_Part protected $_basepart = false; /** + * The charset to output the headers in. + * + * @var string + */ + protected $_hdrCharset = null; + + /** * Function to run on serialize(). */ public function __sleep() @@ -601,6 +608,28 @@ class Horde_Mime_Part } /** + * Set the character set to use when outputting MIME headers. + * + * @param string $charset The character set. + */ + public function setHeaderCharset($charset) + { + $this->_hdrCharset = $charset; + } + + /** + * Get the character set to use when outputting MIME headers. + * + * @return string The character set. + */ + public function getHeaderCharset() + { + return is_null($this->_hdrCharset) + ? $this->getCharset() + : $this->_hdrCharset; + } + + /** * Set the description of this part. * * @param string $description The description of this part. @@ -1026,7 +1055,7 @@ class Horde_Mime_Part if (!empty($this->_temp['toString'])) { $hdr_ob->replaceHeader('Content-Transfer-Encoding', $this->_temp['toString']); } - array_unshift($parts, $hdr_ob->toString(array('charset' => $this->getCharset(), 'defserver' => $options['defserver']))); + array_unshift($parts, $hdr_ob->toString(array('charset' => $this->getHeaderCharset(), 'defserver' => $options['defserver']))); } $newfp = $this->_writeStream($parts); @@ -1457,7 +1486,7 @@ class Horde_Mime_Part } } - $result = $mailer->send(Horde_Mime::encodeAddress($email, $this->getCharset()), $headers->toArray(array('charset' => $this->getCharset())), $msg); + $result = $mailer->send(Horde_Mime::encodeAddress($email, $this->getCharset()), $headers->toArray(array('charset' => $this->getHeaderCharset())), $msg); $this->_basepart = $old_basepart; diff --git a/framework/Mime/package.xml b/framework/Mime/package.xml index ec8b32ae8..8762c0873 100644 --- a/framework/Mime/package.xml +++ b/framework/Mime/package.xml @@ -31,7 +31,8 @@ http://pear.php.net/dtd/package-2.0.xsd"> alpha LGPL - * Add 'raw' render view to Horde_Mime_Viewer. + * Request #8556: Allow specifying a header charset for a part. + * Add 'raw' render view to Horde_Mime_Viewer. * Horde_Mime_Part::parseMessage() correctly parses non-MIME parts. * Remove dependence on PEAR's Mail_mimeDecode::. * Added Horde_Mime::uudecode(). -- 2.11.0