ZF-4819: long mail subject bad encoding


When setting a long subject with accent it break the mail

it seems the probleme come from the line return in case of subject encode in quoted printable format.

The encoding is done like this : Subject: Un exemple de texte =?ISO-8859-1?Q?tr=E8s_long_avec_des_= accents_qui_posent_probl=E8me?=

And according to rfc it must be done like this : Subject: Un exemple de texte =?ISO-8859-1?Q?tr=E8s_long_avec_des_?= =?ISO-8859-1?Q?accents_qui_posent_probl=E8me?=



can confirm this.

same problem.

This is not a big error only a small easy amendable mistake.

The Zend_Mail encodes the subject in the _encodeHeader() function with this:

$quotedValue = Zend_Mime::encodeQuotedPrintable($value); (398. line in the 1.7)

Zend_Mime::encodeQuotedPrintable() uses 74 for the default line length (Zend_Mime::LINELENGTH = 74)

So, this is the problem: Zend_Mime encodes the value (subject) but it is too long for one line. Zend_Mime splits a line.

If you changes the _encodeHeader() to encodes the header vales with $quotedValue = Zend_Mime::encodeQuotedPrintable($value, 200); it will be ok.

So there are the missing length parameter.

It would be nice a a configurable length parameter in the Zend_Mail, maybe...

I am a hungarian. We uses a strange chars like őúőéáűüöóí... So this chars encoded line will be long... 74 char is not enough to us :D


in the meanwhile I found this function to override the original one in Zend_Mail:

protected function encodeHeader($value) { if (Zend_Mime::isPrintable($value)) { return $value; } else { $quotedValue = Zend_Mime::encodeQuotedPrintable($value); $quotedValue = str_replace(array('?', ' ', '', '=' . Zend_Mime::LINEEND), array('=3F', '=20', '=5F', ''), $quotedValue); return '=?' . $this->_charset . '?Q?' . $quotedValue . '?='; } }

by using this all works fine. No more interrupted subjects in mails.

regards, marco

I think it duplicates ZF-1688