login about faq


I have problem with e-mail encoding. I try to send a base64 encoded mail with this code:

$mailman = new CkMailMan();

$email = new CkEmail();
$email->AddHeaderField("Content-Transfer-Encoding", "base64");
$email->AddHeaderField("MIME-Version", "1.0");
$email->AddHeaderField("Content-Type", "text/html; charset=utf-8");
$email->AddHeaderField("X-Priority", "1");
$email->AddHeaderField("X-MSMail-Priority", "High");
$email->AddHeaderField("Importance", "High");
$email->AddHeaderField("From", "=?UTF-8?B?".base64_encode("From Name")."?=\n"." <from_mail@aaa.bbb>");          
$email->SetHtmlBody("An HTML body.");
$email->put_From("From Name <from_mail@aaa.bbb>");
$email->AddTo("To Name", "to_mail@aaa.bb");

The sending is successfull but the content is not encoded. What's wrong with my code?

Regards, Adam

asked Aug 15 '12 at 12:54

dss's gravatar image



The Content-Transfer-Encoding header field applies to the MIME body, but not the headers. The Chilkat Mail API is designed to automatically handle things such as encoding/decoding, charset conversion, etc. For example, if Asian language chars are included in the Subject, or From/To names, then those header fields will automatically be "B" encoded, using the charset of the email, whatever that may be. On the other hand, if 8bit latin chars are present, then the header fields containing those chars might be "Q" encoded. Chilkat will automatically choose the most appropriate encoding. If the chars are 7bit us-ascii, then there is no need for "Q" or "B" encoding.

I'm sorry to say that it's not possible to explicitly do what you are requesting. You may find it odd, but on the other hand, if Chilkat didn't do so many things automatically, then the learning curve for sending and/or reading email would be orders of magnitudes higher.


answered Aug 15 '12 at 19:10

chilkat's gravatar image

chilkat ♦♦

Thank you for your reply!


answered Aug 17 '12 at 02:02

dss's gravatar image


Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported



Asked: Aug 15 '12 at 12:54

Seen: 6,329 times

Last updated: Aug 17 '12 at 02:02

powered by OSQA