Become Zend Certified

Prepare for the ZCE exam using our quizzes (web or iPad/iPhone). More info...

When you're ready get 7.5% off your exam voucher using voucher CJQNOV23 at the Zend Store

Character Sets

Zend_Mail does not check for the correct character set of the mail parts. When instantiating Zend_Mail, a charset for the e-mail itself may be given. It defaults to iso-8859-1. The application has to make sure that all parts added to that mail object have their content encoded in the correct character set. When creating a new mail part, a different charset can be given for each part.

Only in text format

Character sets are only applicable for message parts in text format.

Example 600. Usage in CJK languages

The following example is how to use Zend_Mail in Japanese. This is one of CJK (aka CJKV ) languages. If you use Chinese, you may use HZ-GB-2312 instead of ISO-2022-JP.

//We suppose that character encoding of strings is UTF-8 on PHP script.
function myConvert($string) {

$mail = new Zend_Mail('ISO-2022-JP');
// In this case, you can use ENCODING_7BIT
// because the ISO-2022-JP does not use MSB.
myConvert('This is the text of the mail.'),
$mail->setFrom(''myConvert('Some Sender'));
$mail->addTo(''myConvert('Some Recipient'));

Zend Framework