0
I am trying to send email through a form but is giving the following error:
Warning: mail(): Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\xampp\htdocs\mail_\proc_mail.php on line 18
by localhost and hosted in the service I hired says the message was delivered but did not arrive in my email, follows the codes: HTML:
<form action="contato_valid.php" method="post" class="frm">
<div class="form-group">
<label for="nome">Nome</label>
<input type="text" class="form-control" id="nome" name="nome" placeholder="Digite seu nome com sobrenome" required>
</div>
<div class="form-group">
<label for="email">E-mail</label>
<input type="email" class="form-control" id="email" name="email" placeholder="Digite seu e-mail">
</div>
<div class="form-group">
<label for="telefone">Telefone</label>
<input type="phone" class="form-control" id="tel" name="tel" placeholder="Digite seu telefone com DDD">
</div>
<div class="form-group">
<label for="assunto">Assunto</label>
<input type="text" class="form-control" id="assunto" name="assunto" placeholder="Digite o assunto">
</div>
<div class="form-group">
<label for="msg" required>Mensagem</label>
<textarea class="form-control" id="msg" name="msg" rows="3" placeholder="Digite sua mensagem aqui"></textarea>
</div>
<input type="submit" class="btn btn-primary mb-2" value="Confirmar">
PHP:
<?php
$nome = $_POST['nome'];
$email = $_POST['email'];
$tel = $_POST ['tel'];
$assunto = $_POST['assunto'];
$msg = $_POST['msg'];
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'From: ' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$enviar = mail("[email protected]", "SMTP Casa de Emaus",
"Nome: " . $nome .
"<br> E-mail: " . $email .
"<br> Telefone:" . $tel .
"<br> Assunto: " . $assunto .
"<br> Mensagem: " . $msg . $headers);
//$enviar = mail($to, $email, $msg);
if (!$enviar) {
echo "<script>
alert('Falha ao enviar mensagem'); location= './index.php';
</script>";
} else {
echo "<script>
alert('Mensagem enviada com sucesso!'); location= './index.php';
</script>";
}
?>
I have tried everything I remember and that my co-workers helped me, but without success