0
I have a form that sends an email message. It turns out that the code I have here does not seem to be working the redirect part to confirmation page or sending error:
<?php
// Destinatário:
$para = "[email protected]";
// Assunto:
$assunto = "ASSUNTO X";
// Data de Envio:
$data_envio = date("d/m/Y h:i:s");
// Dados do Formulário:
$email = $_POST["email"];
$mensagem = "MSG X";
$mensagem .= "Enviado em $data_envio.";
$headers = "MIME-Version: 1.1\r\n";
$headers .= "Content-Type:text/html; charset=UTF-8\r\n";
$headers .= "From: $para\r\n";
$headers .= "Return-Path: $para\r\n";
$headers .= "Reply-To: $email\r\n";
$envio = mail($para, $assunto, $mensagem, $headers);
if($envio) {
header("location:respostaform_ok.html");
}
else {
header("location:respostaform_erro.html");
}
?>
I can receive the message by email, but the user sending the msg cannot see the confirmation page.
Could someone help? Thank you.
You can’t have any output before the header function, so make sure you don’t have echo, var_dump, or print_r inside your mail function. And give an Exit right after the header.
– David Alves