2017-12-09 1 views
0

phpmailer 6.0を使用してメールを送信しようとしています。私は私のphpのバージョンを更新し、私はGmailを使用しているので、私のメールは "安全性の低いアプリケーションを確認する"ようにしました。SMTPエラー:localhost XAMPPのphpmailer 6.0を使用してサーバに接続できません

私はこのようなエラーが出る:

2017-12-09 23:30:09 SMTP ERROR: Failed to connect to server: (0) SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting Message could not be sent.Mailer Error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

私はreadmeファイルからのサンプルコードを使用しています。

<?php 
use PHPMailer\PHPMailer\PHPMailer; 
use PHPMailer\PHPMailer\SMTP; 
use PHPMailer\PHPMailer\Exception; 

require 'PHPMailer-master/src/PHPMailer.php'; 
require 'PHPMailer-master/src/SMTP.php'; 
require 'PHPMailer-master/src/Exception.php'; 

$mail = new PHPMailer(true);      
try { 

$mail->SMTPDebug = 2;         
$mail->isSMTP();          
$mail->Host = 'smtp.gmail.com'; 
$mail->SMTPAuth = true;        
$mail->Username = '[email protected]';     
$mail->Password = 'password';       
$mail->SMTPSecure = 'ssl';        
$mail->Port = 465;          
$mail->setFrom('[email protected]'); 
$mail->addAddress('[email protected]');  

$mail->isHTML(true);         
$mail->Subject = 'hello'; 
$mail->Body = 'dasdasd'; 
$mail->AltBody = 'dasdasd'; 

$mail->send(); 
echo 'Message has been sent'; 
} catch (Exception $e) { 
    echo 'Message could not be sent.'; 
    echo 'Mailer Error: ' . $mail->ErrorInfo; 
} 
?> 

※phpmailerをダウンロードしたときにベンダーフォルダがないため、作者を使用していません。

+0

コメントを// $ mail-> isSMTP()を使用していますエラーです。 $ mail-> isSMTPのメール機能が開始されない場合は、 –

+0

をチェックしてください。 – Harukanoo

+0

コメントアウトisSMTPはこれを解決できません。あなたはGmailアドレスから送信しているので、** SMTP経由でGmailを送信する必要があります**。おそらくこれはTLSの問題です。より多くの接続情報を取得するにはSMTPDebug = 3に設定し、トラブルシューティングガイドでそのことについて話してください。 – Synchro

答えて

1

これは私がSMTPのデバッグ= 3

2017-12-10 08:22:52 Connection: opening to ssl://smtp.gmail.com:465, timeout=300, options=array() 2017-12-10 08:22:52 Connection failed. Error #2: stream_socket_client(): SSL operation failed with code 1. OpenSSL Error messages:error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed [D:\Software\XAMPP\htdocs\check334\PHPMailer-master\src\SMTP.php line 325] 2017-12-10 08:22:52 Connection failed. Error #2: stream_socket_client(): Failed to enable crypto [D:\Software\XAMPP\htdocs\check334\PHPMailer-master\src\SMTP.php line 325] 2017-12-10 08:22:52 Connection failed. Error #2: stream_socket_client(): unable to connect to ssl://smtp.gmail.com:465 (Unknown error) [D:\Software\XAMPP\htdocs\check334\PHPMailer-master\src\SMTP.php line 325] 2017-12-10 08:22:52 SMTP ERROR: Failed to connect to server: (0) SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting Message could not be sent.Mailer Error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

関連する問題