2017-12-05 5 views
1

にGmailのポート465または587で、時には正しく動作しません。 。 OpenSSL ExtensionはPHP Config /PHP.iniファイルでも有効ですが、正常に動作しますが、安定していないか正しく動作しています。phpmailerのは、私はGmailのSMTPポートと<strong>LOCALHOST</strong>に<strong>phpmailerの6.0.2</strong>の最新バージョンを使用していますローカルホスト

SMTPエラー:SMTPホストに接続できませんでした。」というエラーを返します。時には465または587ポートにも出力されます。

はとして今、それはここでは587

にポート587上の正確なエラーです。 HERE

2017-12-05 13:00:26 Connection: opening to smtp.gmail.com:587, timeout=300, options=array ('ssl' => array ('verify_peer' => false, 'verify_peer_name' => false, 'allow_self_signed' => true,),) 
2017-12-05 13:00:26 Connection: opened 
2017-12-05 13:00:26 SMTP INBOUND: "220 smtp.gmail.com ESMTP f3sm245851pgt.15 - gsmtp" 
2017-12-05 13:00:26 SERVER -> CLIENT: 220 smtp.gmail.com ESMTP f3sm245851pgt.15 - gsmtp 
2017-12-05 13:00:26 CLIENT -> SERVER: EHLO localhost 
2017-12-05 13:00:27 SMTP INBOUND: "250-smtp.gmail.com at your service, [110.36.136.72]" 
2017-12-05 13:00:27 SMTP INBOUND: "250-SIZE 35882577" 
2017-12-05 13:00:27 SMTP INBOUND: "250-8BITMIME" 
2017-12-05 13:00:27 SMTP INBOUND: "250-STARTTLS" 
2017-12-05 13:00:27 SMTP INBOUND: "250-ENHANCEDSTATUSCODES" 
2017-12-05 13:00:27 SMTP INBOUND: "250-PIPELINING" 
2017-12-05 13:00:27 SMTP INBOUND: "250-CHUNKING" 
2017-12-05 13:00:27 SMTP INBOUND: "250 SMTPUTF8" 
2017-12-05 13:00:27 SERVER -> CLIENT: 250-smtp.gmail.com at your service, [110.36.136.72]250-SIZE 35882577250-8BITMIME250-STARTTLS250-ENHANCEDSTATUSCODES250-PIPELINING250-CHUNKING250 SMTPUTF8 
2017-12-05 13:00:27 CLIENT -> SERVER: STARTTLS 
2017-12-05 13:00:27 SMTP INBOUND: "" 
2017-12-05 13:00:27 SERVER -> CLIENT: 
2017-12-05 13:00:27 SMTP ERROR: STARTTLS command failed: 
SMTP Error: Could not connect to SMTP host. 
2017-12-05 13:00:27 SMTP NOTICE: EOF caught while checking if connected 
2017-12-05 13:00:27 Connection: closed 
SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting  
Mailer Error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting 

関連するコードIS:

use PHPMailer\PHPMailer\PHPMailer; 
use PHPMailer\PHPMailer\OAuth; 
use League\OAuth2\Client\Provider\Google; 

require '../../vendor/autoload.php'; 
$mail = new PHPMailer; 
$mail->isSMTP(); 
$mail->SMTPDebug = 4; 

$mail->Host = 'smtp.gmail.com'; 
$mail->Port = 587; 

$mail->SMTPSecure = 'tls'; 
$mail->SMTPAuth = true; 
$mail->SMTPAutoTLS = false; 

$mail->SMTPOptions = array(
    'ssl' => array(
     'verify_peer' => false, 
     'verify_peer_name' => false, 
     'allow_self_signed' => true 
    ) 
); 

$mail->Username = $from_address; 
$mail->Password = $from_password; 
$mail->SetLanguage("tr", "phpmailer/language"); 
$mail->CharSet = "utf-8"; 
$mail->Encoding = "base64"; 
$mail->SetFrom($from_address, $from_name); 

foreach ($to_email_list as $to) { 
    $mail->AddAddress($to); 
} 

$mail->AddReplyTo($from_address, $from_name); 
$mail->Subject = $email_subject; 

//Creating Email Body 
$message = "<html>\n"; 
$message .= "<body>\n"; 
$message .= '<p>Greetings,</p>'; 
$message .= '<p>' . $email_message . '</p>'; 
$message .= "</body>\n"; 
$message .= "</html>\n"; 
$mail->isHTML(true); 
$mail->MsgHTML($message); 

if(!$mail->Send()) { 
    echo "On Port: " . $from_smtp_port . " </br> Mailer Error: " . $mail->ErrorInfo; 
} else { 
    echo "Message sent! on Port " . $from_smtp_port . "</br>"; 

    foreach($to_email_list as $list){ 
     echo $list . "</br>"; 
    } 

} 
+0

これはTLSエラーです。トラブルシューティングガイドに記載されている内容を読んで実行し、エラーを診断して解決する方法を説明します。 – Synchro

+0

ありがとう!もう少し手伝っていただけますか? –

+0

エラーメッセージのリンクに従ってください。 – Synchro

答えて

0

最後に、私は同じ問題に直面している他のユーザーに推薦するtroubleshooting guide.

に解決策を見つけました。トラブルシューティングガイドで次の点を注意深く参照してください。 - 日和見TLS - PHP 5.6証明書の検証に失敗し - cURLのエラー60

私のスクリプトは、GmailのSS/465およびTLS/587で正常に動作しています。

ありがとうございます! @シンクロ。

関連する問題