Code: Select all
<?php
/* ****************************UTF-8************************************** */
function autoUTF($s)
{
if (preg_match('#[\x80-\x{1FF}\x{2000}-\x{3FFF}]#u', $s)) // detect UTF-8
{
return $s;
}
elseif (preg_match('#[\x7F-\x9F\xBC]#', $s)) // detect WINDOWS-1250
{
return iconv('WINDOWS-1250', 'UTF-8', $s);
}
else // assume ISO-8859-2
{
return iconv('ISO-8859-2', 'UTF-8', $s);
}
}
function cs_mail($to, $predmet, $zprava, $head = "")
{
$predmet = "=?utf-8?B?".base64_encode(autoUTF($predmet))."?=";
$head .= "MIME-Version: 1.0\n";
$head .= "Content-Type: text/plain; charset=\"utf-8\"\n";
$head .= "Content-Transfer-Encoding: base64\n";
$zprava = base64_encode(autoUTF($zprava));
return mail($to, $predmet, $zprava, $head);
}
/* ********************************************************************** ** */
$from = "From: $email\r\n";
cs_mail("mymail@mymail.sk","Správa zo stránky www.transportexpert.sk","Táto správa bola vygenerovaná z online systému:\n
---------------------- Správa ------------------------\n
Meno: " . $_POST['meno'] . "\n
Telefón: " . $_POST['cislo'] . " \n
Mail: " . $_POST['email'] . " \n
Text správy: " . $_POST['sprava'] . " \n
------------------------------------------------------ \n
",$from);
include("sent.html");
?>