Details
Description
When generating a multipart (text and html) message, Zend_Mail includes the following in the headers:
Content-Type: multipart/alternative; charset=iso-8859-1;
boundary="=--whatever--"
As far as I can tell, the charset parameter is not appropriate to a multipart/alternative Content-Type declaration.
from RFC 2045, p. 10:
For example, the "charset" parameter is applicable to any subtype of
"text", while the "boundary" parameter is required for any subtype of
the "multipart" media type.
At http://www-01.ibm.com/support/docview.wss?rs=180&uid=swg1PK48897 I found this:
The
charset parameter isn't valid in the headers
of ANY multipart type. Neither the
multipart/related specification nor any
example in any specification suggests that
it should be allowed. It only applies to
text and to text-related formats such as
application/xml. The body of a
multipart/related document is not text so it
cannot have a charset. It is a collection
of parts which are required to consist of
valid 7-bit ASCII headers combined with data
in whatever encoding is specified in the
content-type and content-encoding headers
for the relevant part.
The inclusion of the charset parameter causes at least one webmail client (UebiMiau 2.7.10) to choke on the message.
modifying the _getHeaders() fucntion in Zend/Mail/Transport/Abstract.php to change this:
$this->_headers['Content-Type'] = array( $type . '; charset=' . $this->_mail->getCharset() . ';' . $this->EOL . " " . 'boundary="' . $boundary . '"' );
to this
$this->_headers['Content-Type'] = array( $type . ';' . $this->EOL . " " . 'boundary="' . $boundary . '"' ); $this->boundary = $boundary; }
Solved the problem with the web client
Also, if a message generated by the existing code is run through message lint at http://www.apps.ietf.org/node/11, it warns: "WARNING: Unexpected parameter 'charset' in header 'Content-Type'"
This fix seems to work for me:
protected function _getHeaders($boundary)
{
if (null !== $boundary) {
// Build multipart mail
$type = $this->_mail->getType();
if (!$type) {
if ($this->_mail->hasAttachments) { $type = Zend_Mime::MULTIPART_MIXED; } elseif ($this->_mail->getBodyText() && $this->_mail->getBodyHtml()) { $type = Zend_Mime::MULTIPART_ALTERNATIVE; } else { $type = Zend_Mime::MULTIPART_MIXED; }
}
$addCharset = !in_array($type, array(
Zend_Mime::MULTIPART_MIXED,
Zend_Mime::MULTIPART_ALTERNATIVE,
Zend_Mime::MULTIPART_MIXED
));
$this->_headers['Content-Type'] = array(
$type . ( $addCharset ? ( '; charset=' . $this->_mail->getCharset() ) : "" ) . ';'
. $this->EOL
. " " . 'boundary="' . $boundary . '"'
);
$this->boundary = $boundary;
}
$this->_headers['MIME-Version'] = array('1.0');
return $this->_headers;
}