Hello.
I installed phpMailer first on the local OpenServer server. Everything worked. But when I switched to the global server / hosting, the mailer stopped working. What is the problem?
Here's the code and the error

 <?php date_default_timezone_set('Europe/Moscow'); require 'phpMailer/PHPMailerAutoload.php'; $mail = new PHPMailer; $mail->IsSMTP(); $mail->Host = 'smtp.gmail.com'; $mail->SMTPAuth = true; $mail->SMTPSecure = 'ssl'; $mail->Port = 465; $mail->CharSet = 'UTF-8'; $body = file_get_contents('content.html'); $mail->Username = 'xxxxxx@gmail.com'; $mail->Password = 'xxxxxx'; $mail->SetFrom('xxxxx@gmail.com', 'xxx'); $mail->Subject = 'Отправка письма с GMAIL'; $mail->MsgHTML($body); $address = 'xxxxx@gmail.com'; $mail->AddAddress($address,'to_xxxx'); if($mail->Send()){ echo 'Письмо отправлено'; }else{ echo $mail->ErrorInfo; } ?> 

Mistake:

 SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting 
  • one
    Looking for hosting options. Maybe there outgoing are blocked (easily) in the framework of the fight against spam - gecube

1 answer 1

Try the mail () function. The function is built-in and does not require additional connections. I use it - normal flight. And less code

  • Spam emails are placed. - Aliev A.
  • IM norm. And without adding email to the white list - sv458