I have a contact form on my site. It takes information such as name, email, phone and message. However, this data is displayed only in the administration panel of the site itself. I would like that at the time of contact the code would take the email informed by the user and send a message directly to my email!
I tried to use the mail function, but I'm not getting any success! How to do it then?!
I used some of them :: Such as
1st. ::
<?php
$nome = $_POST['nome']; echo $nome; echo "<br>";
$email = $_POST['email']; echo $email; echo "<br>";
$mensagem = $_POST['mensagem']; echo $mensagem; echo "<br>";
$corpo = "Nome: ".$nome."<BR>\n";
$corpo .= "Email: ".$email."<BR>\n";
$corpo .= "Mensagem: ".$mensagem."<BR>\n";
if(mail("[email protected]","Assunto",$corpo)){
echo("email enviado com sucesso");
} else {
echo("Erro ao enviar e-mail");
}
?>
In this example, it simply returns "error sending email", without further details.
2. ::
<?php
$email_remetente = "[email protected]";
$headers = "MIME-Version: 1.1\n";
$headers .= "Content-type: text/plain; charset=iso-8859-1\n";
$headers .= "From: $email_remetente\n"; // remetente
$headers .= "Return-Path: $email_remetente\n"; // return-path
$headers .= "Reply-To: $email_usuario\n"; // Endereço (devidamente validado) que o seu usuário informou no contato
$envio = mail("[email protected]", "Assunto", "Mensagem", $headers, "-f$email_remetente");
?>
The recipient will always be the same - my email - what will change will always be the subject, message and sender.