Hi Simone,
the code for sending emails are following:
$tr = new Zend_Mail_Transport_Smtp($mailConfig->host,
$mailConfig->options->toArray());
Zend_Mail::setDefaultTransport($tr);
$mail = new Zend_Mail('utf8');
$mail->setBodyHtml($body);
$mail->setBodyText($body);
$mail->setFrom($mailConfig->from, $mailConfig->sender);
$mail->addTo($email);
$mail->setSubject($subject);
try {
$mail->send();
return true;
} catch (Exception $e) {
return false;
}
and the subject and body contains Chinese characters.
I search the solution for solve this problem,and i found that the problem
would be in the Zend_Mail::_encodeHeader() methods.
the code of the _encodeHeader() methods are following:
protected function _encodeHeader($value)
{
if (Zend_Mime::isPrintable($value)) {
return $value;
} else {
$quotedValue = Zend_Mime::encodeQuotedPrintable($value);
$quotedValue = str_replace(array('?', ' '), array('=3F', '=20'),
$quotedValue);
return '=?' . $this->_charset . '?Q?' . $quotedValue . '?=';
}
}
if change it like this:
protected function _encodeHeader($value)
{
if (Zend_Mime::isPrintable($value)) {
return $value;
} else {
return '=?'.$this->_charset.'?B?'.base64_encode($value).'?=';
}
}
the problem is soloved.
2007/12/29, Jacky Chen <[EMAIL PROTECTED]>:
>
> Hi Simone,
>
> the code for sending emails are following:
>
>
> $tr = new Zend_Mail_Transport_Smtp($mailConfig->host,
> $mailConfig->options->toArray());
> Zend_Mail::setDefaultTransport($tr);
> $mail = new Zend_Mail('utf8');
>
> $mail->setBodyHtml($body);
> $mail->setBodyText($body);
> $mail->setFrom($mailConfig->from, $mailConfig->sender);
> $mail->addTo($email);
> $mail->setSubject($subject);
> try {
> $mail->send();
> return true;
> } catch (Exception $e) {
> return false;
> }
> and the subject and body contains Chinese characters.
>
>
> 2007/12/29, Simone Carletti <[EMAIL PROTECTED]>:
> >
> >
> > It would be helpful if you post here a sample code you use for sending
> > emails.
> > A real example would be wonderful. :)
> >
> > -- Simone
> >
> >
> > Jacky Chen-2 wrote:
> > >
> > > Hi all,
> > >
> > > I send mail with Zend_Mail,and i received the mail body as
> > following.What
> > > is
> > > the problem?
> > >
> > > =E5=96=84=E8=B5=84=E6=96=99?=
> > > Content-Type: multipart/alternative; charset="utf8";
> > > boundary="=_a63f032d182e04daf6311fe5329bef65"
> > > MIME-Version: 1.0
> > >
> > > --=_a63f032d182e04daf6311fe5329bef65
> > > Content-Type: text/plain; charset="utf8"
> > > Content-Transfer-Encoding: quoted-printable
> > >
> > >
> > =E4=BA=B2=E7=88=B1=E7=9A=84=E7=94=A8=E6=88=B7=E6=82=A8=E5=A5=BD=EF=BC=81<p=
> > >>=E6=AC=A2=E8=BF=8E=E5=8A=A0=E5=85=A5HeySpace=E5=A4=A7=E5=AE=B6=E5=BA=AD=
> >
> > >
> > =EF=BC=8C=E8=AF=B7=E7=82=B9=E5=87=BB=E4=BB=A5=E4=B8=8B=E9=93=BE=E6=8E=A5=
> > > =E5=AE=8C=E5=96=84=E6=82=A8=E7=9A=84=E8=B5=84=E6=96=99=EF=BC=9A<br />
> > > /passport/register/email/jacky.hf%40gmail.com/active/ec=
> > > 61998014a83f48a84e0b3dbafeb01f </p>
> > >
> > > --=_a63f032d182e04daf6311fe5329bef65
> > > Content-Type: text/html; charset="utf8"
> > > Content-Transfer-Encoding: quoted-printable
> > >
> > >
> > =E4=BA=B2=E7=88=B1=E7=9A=84=E7=94=A8=E6=88=B7=E6=82=A8=E5=A5=BD=EF=BC=81<p=
> >
> > >>=E6=AC=A2=E8=BF=8E=E5=8A=A0=E5=85=A5HeySpace=E5=A4=A7=E5=AE=B6=E5=BA=AD=
> > >
> > =EF=BC=8C=E8=AF=B7=E7=82=B9=E5=87=BB=E4=BB=A5=E4=B8=8B=E9=93=BE=E6=8E=A5=
> > > =E5=AE=8C=E5=96=84=E6=82=A8=E7=9A=84=E8=B5=84=E6=96=99=EF=BC=9A<br />
> > > /passport/register/email/jacky.hf%40gmail.com/active/ec=
> > > 61998014a83f48a84e0b3dbafeb01f </p>
> > >
> > > --=_a63f032d182e04daf6311fe5329bef65--
> > >
> > >
> >
> > --
> > View this message in context:
> > http://www.nabble.com/Zend_Mail-Bug--tp14521843s16154p14532427.html
> > Sent from the Zend Framework mailing list archive at
> > Nabble.com<http://nabble.com/>
> > .
> >
> >
>