Вот код, который я использую:
Код: Выделить всё
require 'PHPMailer-master/PHPMailerAutoload.php';
$mail = new PHPMailer(true); // create a new object
$mail->IsSMTP(); // enable SMTP
$mail->SMTPDebug = 1; // debugging: 1 = errors and messages, 2 = messages only
$mail->SMTPAuth = true; // authentication enabled
$mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for Gmail
$mail->Host = 'smtp.gmail.com';
$mail->Port = 465; // or 587 465-for gmail
$mail->CharSet = 'UTF-8';
$mail->IsHTML(false);
$mail->Username = '***@gmail.com';
$mail->Password = '*****';
$mail->SetFrom('****@gmail.com');
$mail->Subject = 'test phpmailer';
$mail->Body = 'body without html';
$mail->AddAddress('****@gmail.com');
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message has been sent";
}Я пытался найти решения на их веб-сайте, поскольку а также общие сведения в Интернете, но я не нашел ничего полезного: Устранение неполадок PHPMailer
Что я пробовал и что вижу:
В CMD:
Код: Выделить всё
ping smtp.gmail.com
Pinging gmail-smtp-msa.l.google.com [108.177.126.108] with 32 bytes of data:
Reply from 108.177.126.108: bytes=32 time=5ms TTL=40
Reply from 108.177.126.108: bytes=32 time=5ms TTL=40
Reply from 108.177.126.108: bytes=32 time=5ms TTL=40
Reply from 108.177.126.108: bytes=32 time=5ms TTL=40
Ping statistics for 108.177.126.108:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 5ms, Maximum = 5ms, Average = 5ms
Код: Выделить всё
telnet smtp.gmail.com 587
220 smtp.gmail.com ESMTP b11sm6804305edc.8 - gsmtp
Когда я запускаю код в рабочей среде, я получаю следующее:
2018-02-25 11:51:48 ОШИБКА SMTP: Не удалось подключиться на сервер: (0) 2018-02-25 11:51:48 Ошибка подключения SMTP(). https://github.com/PHPMailer/PHPMailer/ ... leshooting
Кто-нибудь знает, как решить эту проблему?
Подробнее здесь: https://stackoverflow.com/questions/489 ... azure-host
Мобильная версия