Problem with PHPMailer, error 500

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

$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       = '';                       //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`

    $mail->setFrom('[email protected]', 'Formulario');
    $mail->addAddress('[email protected]', 'Mailer2');     //Add a recipient

    $mail->isHTML(true);                                  //Set email format to HTML
    $mail->Subject = 'Formulario';
    $mail->Body    = $body;
    $mail->CharSet = 'UTF-8';
    echo '<script>
    	alert("El mensaje se ha enviado correctamente // Message has been sent");
} catch (Exception $e) {
    echo "Hubo un error al haber enviado el mensaje // Message could not be sent. Mailer Error: {$mail->ErrorInfo}";


I am having a hard time reading your code, but from what I can see, $_GPOST is not a variable.

Change this to 4.


Oh wow, thanks a lot for the quick response.
I’ll check everything and let you know if anything work.

Thanks, again.

Ok, i made it work, had a few syntax error and the port was wrong too, but now it work. I’m crying. Thanks a lot for the help, and i really mean it.


I’m glad I could help you :grin:


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.