I’m trying to send a mail from my contact form using PHPMailer. It is working fine in localhost but I have a problem here on InfinityFree
What I’m seeing is: HTTP ERROR 500
Here;s my PHP Code for sending the mail:
<?php
date_default_timezone_set('Etc/UTC');
ini_set('display_errors','On');
error_reporting(E_ALL);
require ("src/PHPMailer.php");
require ("src/Exception.php");
require ("src/SMTP.php");
require ("src/OAuth.php");
require ("src/POP3.php");
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Host = 'smtp.gmail.com';
$mail->Port = 587;
$mail->SMTPSecure = 'tls';
$mail->SMTPAuth = true;
$mail->Username = 'myusername';
$mail->Password = 'mypassword';
$mail->SMTPDebug = 2;
$mail->setFrom('[email protected]', 'Name');
$mail->addAddress('[email protected]', 'Name');
$mail->Subject = 'Test';
if(!$mail->send()) {
echo ‘Message was not sent.’;
echo 'Mailer error: '. $mail->ErrorInfo;
} else {
echo 'Message has been sent.';
}
Please help me with this. Thanks in Advance.