Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.5k views
in Technique[技术] by (71.8m points)

email - php mail special characters utf8

I have the following script:

<?php
    $subject = "Testmail — Special Characters";
    $msg = "Hi there,

this isn’t something easy.

I haven’t thought that it’s that complicated!";

    mail($to,$subject,$msg,$from."
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
");
?>

In the e-mail:

Subject: Testmail ? Special Characters

Body:

Hi there,

this isn?t something easy.

I haven?t thought that it?s that complicated!

I tried a lot of things, but I have no ideas anymore. Can you help me? Did you ever got this working?

THX!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Did you try iconv_set_encoding ?

This should work :

<?php
 iconv_set_encoding("internal_encoding", "UTF-8");

$subject = "Testmail — Special Characters";
$msg = "Hi there,

this isn’t something easy.

I haven’t thought that it’s that complicated!";

mail(utf8_decode($to), utf8_decode($subject), utf8_decode($msg), utf8_decode($from)."
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
");?>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...