PHPMailer doesn't work

My website URL is:

What I’m seeing is:

502 Bad Gateway

I’m using this software:

I’m simply using PHPMailer like the example in your website but i always see the same error “502 Bad Gataway”, why?! Please help me, i want only simply send a mail. Below my code:



require (“PHPMailer.php”);
require (“Exception.php”);
require (“SMTP.php”);
require (“OAuth.php”);
require (“POP3.php”);

$mail = new PHPMailer\PHPMailer\PHPMailer();

$mail->Host = ‘’;
$mail->Port = 587;
$mail->SMTPSecure = ‘tls’;
$mail->SMTPAuth = true;
$mail->Username = $myusername;
$mail->Password = $mypsw;
$mail->SMTPDebug = 2;

$mail->setFrom(‘’, ‘Awesome Website’);
$mail->addAddress(‘’, ‘John Doe’);
$mail->Subject = ‘PHPMailer GMail SMTP test’;

if(!$mail->send()) {
echo ‘Message was not sent.’;
echo 'Mailer error: ’ . $mail->ErrorInfo;
} else {
echo ‘Message has been sent.’;

I checked your code, and I think the issue is caused by an include loop.

In the code you shared, you have the line require ("PHPMailer.php");. However, I have checked this file “PHPMailer.php”, but that file also contains a script like what you’ve shared here.

Can you please make sure the file PHPMailer.php contains the actual PHPMailer library, and see if you can have another script which uses that library?

yes, the error was this… :sweat: thanks!

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