Error sending email to localhost

Asked

Viewed 29 times

0

I am trying to send emails via html data, using xampp, but is returning me 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 Sch enviar.php on line 12"

Codes: send php.:

<?php
  $nome = $_POST['nome']; 
   $email = $_POST['email'];
   $assunto = $_POST['assunto'];
   $mensagem = $_POST['mensagem'];

mail (
    "[email protected]", //Endereço que vai receber a mensagem
    "Nome: $nome
     Email: $email
     Assunto: $assunto
     Mensagem: $mensagem", "FROM:$nome<$email>");
?>
<!DOCTYPE html>
<html>
<head>
    <title>aaa</title>
</head>
<body>
    <form method="POST" name="meu-form" action="?">     
        Nome: <input type="text" name="nome">     
        Email:    <input type="text" name="email">     
        Assunto: <input type="text" name="assunto">
        Mensagem:  <textarea name="mensagem"></textarea>     
        <input type="submit" value="Enviar">
    </form>
</body>
</html>

php.ini:

SMTP=smtp.gmail.com
smtp_port=587
sendmail_from = [email protected]
sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"

sendmail.ini:

smtp_server=smtp.gmail.com
smtp_port=587
error_logfile=error.log
debug_logfile=debug.log
[email protected]
auth_password=my-gmail-password
[email protected]
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.