[Solved] php mail form doesn’t work [closed]


The below now works. It’s just small syntactic mistakes, you had a few additional ; and this line is wrong and presumably a mistake: $subject = $email = $_POST['subject'];

I also moved the function outside of the if statement…it’s not incorrect to have it there, it just looks a bit weird.

function clean_text($string) {
    $bad = array("content-type","bcc:","to:","cc:","href");
    return str_replace($bad,"",$string);
}

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

    $email_to = $email;
    $header="From: 1totheN <[email protected]>" . "\r\n";
    $email_message .= "Name: ".clean_text($email)."\n";
    $email_message .= "Email: ".clean_text($email)."\n";
    $email_message .= "Message: ".clean_text($message)."\n";
    @mail($email_to, $subject, $email_message, $header);
    echo "Your message has been sent.";
}
?>

1

solved php mail form doesn’t work [closed]