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