1 <?xml version="1.0" encoding="UTF-8"?>
3 <sect1 id="zend.mail.encoding">
4 <title>Encoding</title>
7 Text and <acronym>HTML</acronym> message bodies are encoded with the quotedprintable
8 mechanism by default. Message headers are also encoded with the quotedprintable mechanism if
9 you do not specify base64 in <methodname>setHeaderEncoding()</methodname>. If you use
10 language that is not Roman letters-based, the base64 would be more suitable. All other
11 attachments are encoded via base64 if no other encoding is given in the
12 <methodname>addAttachment()</methodname> call or assigned to the <acronym>MIME</acronym>
13 part object later. 7Bit and 8Bit encoding currently only pass on the binary content data.
17 Header Encoding, especially the encoding of the subject, is a tricky topic.
18 <classname>Zend_Mime</classname> currently implements its own algorithm to encode quoted
19 printable headers according to RFC-2045. This due to the problems of
20 <code>iconv_mime_encode</code> and <code>mb_encode_mimeheader</code> with regards to certain
21 charsets. This algorithm only breaks the header at spaces, which might lead to headers that
22 far exceed the suggested length of 76 chars. For this cases it is suggested to switch to
23 BASE64 header encoding same as the following example describes:
26 <programlisting language="php"><![CDATA[
27 // By default Zend_Mime::ENCODING_QUOTEDPRINTABLE
28 $mail = new Zend_Mail('KOI8-R');
30 // Reset to Base64 Encoding because Russian expressed in KOI8-R is
31 // different from Roman letters-based languages greatly.
32 $mail->setHeaderEncoding(Zend_Mime::ENCODING_BASE64);
36 <classname>Zend_Mail_Transport_Smtp</classname> encodes lines starting with one dot or two
37 dots so that the mail does not violate the SMTP protocol.