/ / PHPMailerを使用して電子メールを送信しますか?エラーを表示する - php、phpmailer

私はPHPMailerを使用して電子メールを送信したいですか?エラーを与える - php、phpmailer

**Error:**SMTP NOTICE: EOF caught while checking if connected SMTP connect() failed.
Mailer Error: SMTP connect() failed.

私のコードは:

<?php
require("class.phpmailer.php");
//require_once("class.phpmailer.php");
//require_once("inc/phpmailer/class.phpmailer.php");
$mail = new PHPMailer();// 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 = 587; // or 465
$mail->IsHTML(true);
$mail->Username = "biz.online321@gmail.com";
$mail->Password = "mudunuru%^&";
$mail->SetFrom("example@gmail.com");
$mail->Subject = "Test";
$mail->Body = "hello";
$mail->AddAddress("varma.sfi123@gmail.com");
print $mail;
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message has been sent";
}

あなたの助けが賢明になります

回答:

回答№1は0

これはあなたの問題です:

$mail->SMTPSecure = "ssl";
$mail->Port = 587;

SSLを非SSLポートに話そうとしています。代わりにこれを行う:

$mail->SMTPSecure = "tls";
$mail->Port = 587;

私はまた、あなたが PHPMailerの最新バージョン 付属のサンプルに基づいてコードを作成してください。