Я использую PHPMailer. Но когда я загружаю на свой хост, я получаю сообщение об ошибке SMTP connect().
Моя среда 1. Серверная ОС: CentOS 7 2. Веб-службы: XAMPP 5.6.8 3. PHPMailer: 5.2.4
это мой код:
<?php
require_once('PHPMailer_old/class.phpmailer.php');
try{
$mail = new PHPMailer(true); // the true param means it will throw exceptions on errors, which we need to catch
$mail->IsSMTP(); // telling the class to use SMTP
$mail->SMTPDebug = 1; // enables SMTP debug information (for testing)
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->SMTPSecure = "ssl";
$mail->SMTPAutoTLS = false; // close TLS
$mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server
$mail->Port = 465; // set the SMTP port for the GMAIL server
$mail->Username = "[email protected]"; // GMAIL username
$mail->Password = "Test"; // GMAIpassword
$mail->FromName = "Test Manager";
$mail->From = "[email protected]";
$to = "[email protected]";
$mail->AddAddress($to);
$mail->Subject = "First PHPMailer Message";
$mail->AltBody = "To view the message, please use an HTML compatible email viewer!";
$mail->WordWrap = 80;
$body = "success!";
$mail->MsgHTML($body);
$mail->IsHTML(true);
$mail->Send();
echo "Message has been sent.";
}catch(phpmailerException $e){
echo "Sending Failed";
echo $e -> errorMessage();
}
?>
Сообщение об ошибке В Интернете: SMTP → ОШИБКА: Не удалось подключиться к серверу: (0) Отправка FailedSMTP Ошибка: не удалось подключиться к узлу SMTP.
Спасибо всем! Мое решение - удалить XAMPP и соответственно установить apache, PHP, MySQL
$mail->Port = 465;
$mail->Port = 25;
и увидеть