1

I am trying so send email with html body, I form it with entries from DB and everything okay, when i check composed message using

echo $message;

I see great composed text without any errors, but after sending it using mail() function, I have trouble with only 1 symbol.

All page and all data in utf-8, header set to utf as well:

$headers .= "Content-type: text/html; charset=utf-8\r\n";

echo result: after echo

gmail result: enter image description here

How can I solve this problem?

4
  • Just curios.. why do you have \r\n in your charset?
    – Bolli
    Feb 8, 2015 at 13:20
  • Could be double encoding.. because Gmail already has charset set?
    – Bolli
    Feb 8, 2015 at 13:21
  • \r\n because I have another lines after
    – nik1004
    Feb 8, 2015 at 13:22
  • i thought about double enconding, but gmail can show it plain, and i have the same error, I thinks it happens when gmail gets my email, but i want understand what to do to avoid it
    – nik1004
    Feb 8, 2015 at 13:27

1 Answer 1

0

I found the solution Added to headers and remove any charset

$headers .= "Content-type: text/html\r\n";
$headers .= "Content-Transfer-Encoding: base64" . "\r\n";

And do that with all my message:

$message = rtrim(chunk_split(base64_encode($message)));

Now everything works!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.