Advertisement
Guest User

Untitled

a guest
Aug 30th, 2011
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. <?php
  2. function autoUTF($s)
  3. {
  4. if (preg_match('#[\x80-\x{1FF}\x{2000}-\x{3FFF}]#u', $s))
  5. {
  6. return $s;
  7. }
  8. elseif (preg_match('#[\x7F-\x9F\xBC]#', $s))
  9. {
  10. return iconv('WINDOWS-1250', 'UTF-8', $s);
  11. }
  12. else
  13. {
  14. return iconv('ISO-8859-2', 'UTF-8', $s);
  15. }
  16. }
  17.  
  18. function cs_mail($to, $predmet, $zprava, $head = "")
  19. {
  20. $predmet = "=?utf-8?B?".base64_encode(autoUTF($predmet))."?=";
  21. $head .= "MIME-Version: 1.0\r\n";
  22. $head .= "Content-Type: text/plain; charset=\"utf-8\"\r\n";
  23. $head .= "Content-Transfer-Encoding: base64\r\n";
  24. $zprava = base64_encode(autoUTF($zprava));
  25. return mail($to, $predmet, $zprava, $head);
  26. }
  27.  
  28. $mail = "gledy@seznam.cz"; //komu email prijde
  29. $jmeno = $_GET["Jmeno"];
  30. $predmet = $_GET["Predmet"];
  31. $zprava = $_GET["Zprava"];
  32. $email = $_GET["Email"];
  33.  
  34. if ($jmeno!="" and $predmet !="" and $zprava !="" and $email!="")
  35. {
  36. if (cs_mail($mail, $predmet, $zprava, 'From:' .$jmeno. '<'.$email.'>'))
  37. {
  38. echo "<script>location.href=\"odeslano.php\"</script>";
  39. }}
  40. else
  41. {
  42. echo "<p>Váši zprávu <strong>nepodařilo odeslat,</strong> pravděpodobně jste nevyplnili všechny povinné údaje, <a href='/kontakt'> <strong>Odeslat znovu</strong></a></p>";
  43. }
  44.  
  45. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement