login about faq

Hello,

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

$mailman = new CkMailMan();
$mailman->UnlockComponent($ck_mail_unlock);
$mailman->put_SmtpHost($smtp_host);
$mailman->put_SmtpUsername($smtp_user);
$mailman->put_SmtpPassword($smtp_pass);
$mailman->put_SmtpPort(587);
$mailman->put_StartTLS(true);

$email = new CkEmail();
$email->put_Utf8(true);
$email->put_Charset('utf-8');
$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->put_Subject("=?UTF-8?B?".base64_encode("Subject")."?=");
$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

dss
16810


Adam,

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.

link

answered Aug 15 '12 at 19:10

chilkat's gravatar image

chilkat ♦♦
11.8k316358421

Thank you for your reply!

link

answered Aug 17 '12 at 02:02

dss's gravatar image

dss
16810

Your answer
toggle preview

Follow this question

By Email:

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

By RSS:

Answers

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

Tags:

×80
×37
×13

Asked: Aug 15 '12 at 12:54

Seen: 3,614 times

Last updated: Aug 17 '12 at 02:02

powered by OSQA