This topic is locked
[SOLVED]

  Missing special chars in sent emails

3/27/2012 8:51:45 PM
PHPRunner General questions
J
Jeroef author

I found this email template and it works, i do send emails out when new items are added.

Problem is the emails that arrives are missing special chars ( å ä ö ).

$email=$values['email']."\r\r\n";

$msg="";

$msg.="<html>

<head>

<title>Anmälan</title>

</head>

<body>

<table width=\"778\" border=\"0\" cellspacing=\"10\" cellpadding=\"10\" style=\"border:1px dashed #DFF2F6;\">

<tr>

<td>

<h2>Välkommen till Tävling ".$values["tnamn"]."</h2>



<p>I med detta email har du anmält dig till Tävling ".$values["tnamn"].".</p>

<p>Du finns nu i vårat system.</p>

<p>Mvh Atletika.</p>
<table border=\"0\" width=\"600\" cellspacing=\"10\" cellpadding=\"0\">

<tr>

<td valign=\"top\">Namn:</td>

<td valign=\"top\">".$values["namn"]."</td>

</tr>

<tr>

<td valign=\"top\">Född: </td>

<td valign=\"top\">".$values["fodd"]."</td>

</tr>

<tr>

<td valign=\"top\">Klubb: </td>

<td valign=\"top\">".$values["klubb"]."</td>

</tr>

<tr>

<td valign=\"top\">Gren: </td>

<td valign=\"top\">".$values["gren"]."</td>

</tr>

<tr>

<td valign=\"top\">Anmälningsdatum:</td>

<td valign=\"top\">".$values["anmaldes"]."</td>

</tr>

</table>
</td>

</tr>

</table>

</body>

</html>

";
$headers = "MIME-Version: 1.0" . "\r\n";

$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";

$subject="Bekräftelse";

$from="admin@sveapp.se";

$ret=runner_mail(array('to' => $email, 'subject' => $subject, 'htmlbody' => $msg, 'from'=>$from));

if(!$ret["mailed"])

{echo $ret["message"];}


Is there a way to fix this?

Sergey Kornilov admin 3/27/2012
J
Jeroef author 3/28/2012



Try UTF-8 charset instead of iso-8859-1
More info:

http://stackoverflow.com/questions/1704182/sending-email-in-php-with-special-characters


While i was trying to get this to work i realised that i didnt need a HTM email, so i modded a simple text email instead.
After record added event on add page.

//********** Send email with new data ************
$email=$values['email'];

$from="Atletika, Tävlingsbekräftelse";

$subject="Anmälan till Tävling!";

$body = "Vi hälsar välkommen till " . $values["tnamn"] . "!\n" . $values["namn"] . ", Född " . $values["fodd"] . " från Klubb " . $values["klubb"] . " är nu anmäld till:\n\nKlass: " . $values["klass"] . "\nGren: " . $values["gren"] . "\nAnmälningsdag: " . $values["anmaldes"] . "\n\nVi passar på att tacka för ditt intresse och önskar lycka till!\n\nMed Vänliga Hälsningar, Tävlingsledningen.";

$arr = runner_mail(array('to' => $email, 'from'=>$from, 'subject' => $subject, 'body' => $body));

$result["txt"] = "Emails were sent.";



// if error happened print a message on the web page

if (!$arr["mailed"])

{

$errmsg = "Error happened:
";

$errmsg.= "File: " . $arr["errors"][0]["file"] . "
";

$errmsg.= "Line: " . $arr["errors"][0]["line"] . "
";

$errmsg.= "Description: " . $arr["errors"][0]["description"] . "
";

$result["txt"] = $errmsg;

}


Now everything works great. Thanks for the help.