Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

php mail special characters utf8

I have the following script:

<?php
    $subject = "Testmail — Special Characters";
    $msg = "Hi there,\n\nthis isn’t something easy.\n\nI haven’t thought that it’s that complicated!";

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

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!

like image 880
John Doe Smith Avatar asked Oct 31 '13 13:10

John Doe Smith


1 Answers

Did you try iconv_set_encoding ?

This should work :

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

$subject = "Testmail — Special Characters";
$msg = "Hi there,\n\nthis isn’t something easy.\n\nI haven’t thought that it’s that complicated!";

mail(utf8_decode($to), utf8_decode($subject), utf8_decode($msg), utf8_decode($from)."\nContent-Type: text/plain; charset=UTF-8\nContent-Transfer-Encoding: 8bit\n");?>
like image 127
Gregosaurus Avatar answered Oct 20 '22 19:10

Gregosaurus