svn: /pear/packages/Mail_Mime/trunk/ mime.php package.xml

From: Date: Mon, 12 Apr 2010 10:57:34 +0000
Subject: svn: /pear/packages/Mail_Mime/trunk/ mime.php package.xml
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-59246@lists.php.net to get a copy of this message
alec Mon, 12 Apr 2010 10:57:34 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=297878 Log: Added Mail_mime::setContentType() function with possibility to set various types in Content-Type header (also fixes problem with boundary parameter when Content-Type header was specified by user) Changed paths: U pear/packages/Mail_Mime/trunk/mime.php U pear/packages/Mail_Mime/trunk/package.xml Modified: pear/packages/Mail_Mime/trunk/mime.php =================================================================== --- pear/packages/Mail_Mime/trunk/mime.php 2010-04-12 10:24:50 UTC (rev 297877) +++ pear/packages/Mail_Mime/trunk/mime.php 2010-04-12 10:57:34 UTC (rev 297878) @@ -1028,6 +1028,7 @@ * $array['header-name'] = 'header-value'; * * @param array $xtra_headers Assoc array with any extra headers (optional) + * (Don't set Content-Type for multipart messages here!) * @param bool $overwrite Overwrite already existing headers. * @param bool $skip_content Don't return content headers: Content-Type, * Content-Disposition and Content-Transfer-Encoding @@ -1064,6 +1065,8 @@ unset($headers['Content-Type']); unset($headers['Content-Transfer-Encoding']); unset($headers['Content-Disposition']); + } else if (!empty($this->_build_params['ctype'])) { + $headers['Content-Type'] = $this->_build_params['ctype']; } $encodedHeaders = $this->_encodeHeaders($headers); @@ -1075,6 +1078,7 @@ * (usefull if you want to use the PHP mail() function) * * @param array $xtra_headers Assoc array with any extra headers (optional) + * (Don't set Content-Type for multipart messages here!) * @param bool $overwrite Overwrite the existing headers with new. * @param bool $skip_content Don't return content headers: Content-Type, * Content-Disposition and Content-Transfer-Encoding @@ -1111,6 +1115,54 @@ } /** + * Sets message Content-Type header. + * Use it to build messages with various content-types e.g. miltipart/raport + * not supported by _contentHeaders() function. + * + * @param string $type Type name + * @param array $params Hash array of header parameters + * + * @return void + * @access public + * @since 1.7.0 + */ + function setContentType($type, $params = array()) + { + $header = $type; + + $eol = !empty($this->_build_params['eol']) + ? $this->_build_params['eol'] : "\r\n"; + + // add parameters + $token_regexp = '#([^\x21,\x23-\x27,\x2A,\x2B,\x2D' + . ',\x2E,\x30-\x39,\x41-\x5A,\x5E-\x7E])#'; + if (is_array($params)) { + foreach ($params as $name => $value) { + if ($name == 'boundary') { + $this->_build_params['boundary'] = $value; + } + if (!preg_match($token_regexp, $value)) { + $header .= ";$eol $name=$value"; + } else { + $value = addcslashes($value, '\\"'); + $header .= ";$eol $name=\"$value\""; + } + } + } + + // add required boundary parameter if not defined + if (preg_match('/^multipart\//i', $type)) { + if (empty($this->_build_params['boundary'])) { + $this->_build_params['boundary'] = '=_' . md5(rand() . microtime()); + } + + $header .= ";$eol boundary=\"".$this->_build_params['boundary']."\""; + } + + $this->_build_params['ctype'] = $header; + } + + /** * Sets the Subject header * * @param string $subject String to set the subject to. Modified: pear/packages/Mail_Mime/trunk/package.xml =================================================================== --- pear/packages/Mail_Mime/trunk/package.xml 2010-04-12 10:24:50 UTC (rev 297877) +++ pear/packages/Mail_Mime/trunk/package.xml 2010-04-12 10:57:34 UTC (rev 297878) @@ -30,9 +30,9 @@ <active>yes</active> </lead> - <date></date> + <date>2010-04-12</date> <version> - <release>1.6.2</release> + <release>1.7.0</release> <api>1.4.0</api> </version> <stability> @@ -41,8 +41,10 @@ </stability> <license uri="http://www.opensource.org/licenses/bsd-license.php">BSD Style</license> <notes> -Bugs Fixed: - * Fix Bug #17226: Non RFC-compliant quoted-printable encoding of structured headers [alec] +Implemented Features: + * Added Mail_mime::setContentType() function with possibility to set various + types in Content-Type header (also fixes problem with boundary parameter when Content-Type + header was specified by user) [alec] </notes> <contents> <dir name="/"> @@ -535,5 +537,21 @@ * Implement Feature #17175: Content-Description support for attachments [alec] </notes> </release> + <release> + <version> + <release>1.6.2</release> + <api>1.4.0</api> + </version> + <stability> + <release>stable</release> + <api>stable</api> + </stability> + <date>2010-03-23</date> + <license uri="http://www.opensource.org/licenses/bsd-license.php">BSD Style</license> + <notes> +Bugs Fixed: + * Fix Bug #17226: Non RFC-compliant quoted-printable encoding of structured headers [alec] + </notes> + </release> </changelog> </package>

« previous php.pear.cvs (#59246) next »