Hi. I use the code, at the bottom, for send easy message form website for years and have not had any problems so far. Now, the fiend of my wanted to insert this code to his website on different server nad the variable $from do not run properly. When I inset this code to any other website on any other different servers, everithing is OK (mail name, value from, message). But on his server the value of variable $form is not the the value form Imput "Email", but allways "xz000500@useron4.hostmaster.sk". Am I do something wrong? Or how can I solve this problem? Thanks.
- 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");
?>