it gives me this 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\LF\html\suggestions .php online 17
<?php
if (isset($_POST['submit'])){
$nombre=$_POST['name'];
$correo=$_POST['email'];
$mensaje=$_POST['mensaje'];
$enviar = '[email protected]';
$asunto = 'Sugerencia';
$header = 'From: ' . $correo;
$msjCorreo = "Nombre: $nombre\n E-Mail: $correo\n Mensaje:\n $mensaje";
if (mail($enviar, $asunto, $msjCorreo, $header)){
echo "<script language='javascript'>
alert('Mensaje enviado, muchas gracias.');
window.history.go(-1);
</script>";
} else {
echo 'Falló el envio';
}
}
?>`
how to configure xampp to send mail from a localhost
How to configure xampp to send emails from a localhost To be able to send emails from localhost it is necessary to configure the php.ini and sendmail.ini with an SMTP account to manage emails. The first is to enter the php.ini and look for the line [mail function] here we will comment sendmail_path by entering the path where our sendmail is installed, for my case it would stay like this.
the second we enter the sendmail.ini that we could find where our xampp server was installed.
And we should be left with something like the following; [email protected]
With this we should be able to send emails from our localhost, I hope it will be useful to you.
Also here is an identical question but on stackoverflow in English:
The question
tutorial source
Although if you are testing your own or business project, I would recommend a free server like hostinger.