3
I have the following code to send the responses of a form from my website to my email:
<?php
//
//Variáveis
$n_nome = $_POST['n-nome'];
$n_email = $_POST['n-email'];
$n_fone = $_POST['n-fone'];
$n_msg = $_POST['n-msg'];
$data_envio = date('d/m/Y');
$hora_envio = date('H:i:s');
//
// Configuração do e-mail
$arquivo = "
<html>
<h1>NOVA MENSAGEM RECEBIDA VIA SITE</h1>
<p>Nome: <b>$n_nome</b></p>
<p>E-mail: <b>$n_email</b></p>
<p>Telefone: <b>$n_fone</b></p>
<p>Mensagem: <br> <b>$n_msg</b></p>
</html>
";
//
//enviar
$emailenviar = "[email protected]";
$destino = $emailenviar;
$assunto = "[SITE CONTATO] $n_nome";
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=utf-8' . "\r\n";
$headers .= 'From: Meu Site <[email protected]>';
$enviaremail = mail($destino, $assunto, $arquivo, $headers);
if($enviaremail){
$mgm = "MENSAGEM RECEBIDA COM SUCESSO!";
echo " <meta http-equiv='refresh' content='2;URL='> "; // Configurar página de destino
} else {
$mgm = "ERRO AO RECEBER MENSAGEM!";
echo "<meta http-equiv='refresh' content='2;URL='>";
}
?>
Now, when I answer the message in my email I have to copy the email form and paste in the appropriate field. He always tries to answer to There’s a way to pre-defame that when I answer he’ll already put the $n_email
as a recipient?
Okay. I switched to
$headers .= 'From: $n_nome <$n_email>';
. But at the time of answering her in the email is "From: $n_name, with the email: [email protected]".– user99005
@Marcoslichtenfels You copied exactly as I did, or you changed the quotes?
– Guilherme Nascimento
It worked. I copied exactly your answer and it worked. Thank you!
– user99005