Package Home

Zend Framework 2 Documentation (Manual)

PHK Home

File: /modules/zend.mail.character-sets.html

Size:10604
Storage flags:no_autoload,compress/gzip (31%)

Character Sets — Zend Framework 2 2.4.2 documentation

Character SetsΒΆ

Zend\Mail\Message does not check for the correct character set of the mail parts. When instantiating Zend\Mail\Message, 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.

Note

Only in text format

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

Usage in CJK languages

The following example is how to use Zend\Mail\Message 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.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
//We suppose that character encoding of strings is UTF-8 on PHP script.
function myConvert($string) {
    return mb_convert_encoding($string, 'ISO-2022-JP', 'UTF-8');
}

$mail = new Zend\Mail\Message('ISO-2022-JP');
// In this case, you can use ENCODING_7BIT
// because the ISO-2022-JP does not use MSB.
$mail->setBodyText(
    myConvert('This is the text of the mail.'),
    null,
    Zend\Mime\Mime::ENCODING_7BIT
);
$mail->setHeaderEncoding(Zend\Mime\Mime::ENCODING_BASE64);
$mail->setFrom('somebody@example.com', myConvert('Some Sender'));
$mail->addTo('somebody_else@example.com', myConvert('Some Recipient'));
$mail->setSubject(myConvert('TestSubject'));
$mail->send();

This Page

Note: You need to stay logged into your GitHub account to contribute to the documentation.

Edit this document

Edit this document

The source code of this file is hosted on GitHub. Everyone can update and fix errors in this document with few clicks - no downloads needed.

  1. Login with your GitHub account.
  2. Go to Character Sets on GitHub.
  3. Edit file contents using GitHub's text editor in your web browser
  4. Fill in the Commit message text box at the end of the page telling why you did the changes. Press Propose file change button next to it when done.
  5. On Send a pull request page you don't need to fill in text anymore. Just press Send pull request button.
  6. Your changes are now queued for review under project's Pull requests tab on GitHub.

For more information about the PHK package format: http://phk.tekwire.net