
Here's a snippet of code I found on a site I built, that works with UTF-8 characters:
Code: Select all
$sTo = $a_sEmail;
$sSubject = utf8_decode("****.se - Nytt Lösenord");
$sMessage = '<html><head><title>****.se - Nytt Lösenord</title></head><body>'
. 'Hej!<br /><br />Här kommer ditt nya lösenord till <a href=\"http://****.se\">****.se</a><br /><br /><pre><b>'
. $sNewPassword
. '</b></pre></body></html>';
$sHeaders = 'MIME-Version: 1.0' . "\r\n";
$sHeaders .= 'Content-type: text/html; charset=utf-8' . "\r\n";
$sHeaders .= 'To: ' . $a_sEmail . ' <' . $a_sEmail . '>' . "\r\n";
$sHeaders .= utf8_decode('From: Ädmíñ文@****.se <admin@****.se>') . "\r\n"; // Changed to strange characters here, displays correctly in inbox
if (mail($sTo, $sSubject, $sMessage, $sHeaders))
{
return MessageConstants::NEW_PASSWORD_SENT_OK;
}
else
{
return MessageConstants::NEW_PASSWORD_SEND_FAILED;
}
Edit: Didn't work to bold text inside CODE, but you can see the two places I use utf8_decode().