Php Mailer mailer error: language line did not load: connect_host?

I keep getting this error.

below is my code:

<?php
ini_set("include_path", "phpmailer/"); 
require 'phpmailer/class.phpmailer.php';
$mailer = new PHPMailer();
$mailer->IsSMTP();
$mailer->Host = 'smtp.gmail.com';
$mailer->Port='465';
$mailer->SMTPAuth = TRUE;
$mailer->Username = 'mail@gmail.com';  // Change this to your gmail adress
$mailer->Password = '****';  // Change this to your gmail password
$mailer->From = 'maile@gmail.com';  // This HAVE TO be your gmail adress
$mailer->FromName = 'Belmer'; // This is the from name in the email, you can put anything you like here
$mailer->Body = 'This is the main body of the email';
$mailer->Subject = 'This is the subject of the email';
$mailer->AddAddress('another@ymail.com');  // This is where you put the email adress of the person you want to mail
if(!$mailer->Send())
{
   echo "Message was not sent<br/ >";
   echo "Mailer Error: " . $mailer->ErrorInfo;
}
else
{
   echo "Message has been sent";
}
?>

Does anyone know this error? Your reply is greatly appreciated.

+3
source share
1 answer

Got! Thanks guys for watching.

Actually there is no problem with the code, it should be some settings on my local server. My solutions - I uploaded files to my live web server and everything is working fine.

0
source

Source: https://habr.com/ru/post/1762635/


All Articles