0

I tried several times to implement UTF-8 for receiving mails from my php contact form, but without any luck.

Code looks like this:

<?php

if (isset($_POST['submit'])) {
    $name = $_POST['name'];
    $subject = $_POST['subject'];
    $mailFrom = $_POST['email'];
    $message = $_POST['message'];

    $mailTo = "info@mnbl.eu";
    $headers = "Od: ".$mailFrom;
    $txt = "Dostal jste e-mail od ".$name.".\n\n".$message;

    mail($mailTo, $subject, $txt, $headers);

    if (empty($name) || empty($subject) || empty($mailFrom) || empty($message)) {
        header("Location: ../page-contact-form.php?form=empty");
        exit();
    } else {
        if (!filter_var($mailFrom, FILTER_VALIDATE_EMAIL)) {
            header("Location: ../page-contact-form.php?form=email");
            exit();
        } else {
            header("Location: ../page-contact-form.php?mailsend");
            exit();
        }
    }       
}

?>

I have <meta charset="UTF-8"> in my head, accept-charset="utf-8"in form tag.

Still i recieve mails with weird symbols (input language is Czech).

Do I need anything else?

Thanks in advance.

0 Answers0