Username (e.g. epiz_XXX) or Website URL
Hello everyone,
I’m new to this so i’m really confused.
I built a form in my web, hosted it here in infinityfree and i’m using phpmailer to get the mail from the form but it is not working, only message i get is error 500, i dont know how to turn on the debugger to know if i have an error in any line- I followed what’s written in the github but i’m confused.
This is my php code
<?php
$fname = $_POST['fname'];
$lname = $_POST['lname'];
$phone = $_GPOST['phone'];
$email = $_POST['email'];
$message = $_POST['message'];
$body = "Nombre: " . $fname . "<br>Apellido: " . $lname . "<br>Telefono: " . $phone "<br>Email: " . $email "<br>Mensaje: " . $message;
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
require 'Mailer/src/Exception.php';
require 'Mailer/src/PHPMailer.php';
require 'Mailer/src/SMTP.php';
$mail = new PHPMailer(true);
try {
//Server settings
$mail->SMTPDebug = SMTP::DEBUG_SERVER; //Enable verbose debug output
$mail->isSMTP(); //Send using SMTP
$mail->Host = 'smtp.gmail.com'; //Set the SMTP server to send through
$mail->SMTPAuth = true; //Enable SMTP authentication
$mail->Username = '[email protected]'; //SMTP username
$mail->Password = 'password'; //SMTP password
$mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS; //Enable implicit TLS encryption
$mail->Port = 587; //TCP port to connect to; use 587 if you have set `SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS`
//Recipients
$mail->setFrom('[email protected]', 'Formulario');
$mail->addAddress('[email protected]', 'Mailer2'); //Add a recipient
//Content
$mail->isHTML(true); //Set email format to HTML
$mail->Subject = 'Formulario';
$mail->Body = $body;
$mail->CharSet = 'UTF-8';
$mail->send();
echo '<script>
alert("El mensaje se ha enviado correctamente // Message has been sent");
window.history.go(-1);
</script>';
} catch (Exception $e) {
echo "Hubo un error al haber enviado el mensaje // Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
}
?>