의 Gmail 포트 465 또는 587에 제대로 가끔 작동하지 않습니다 [465 및 TLS에 SSL을 587] . OpenSSL Extension이 PHP Config /PHP.ini 파일에서도 활성화되어 있지만 잘 작동하지만 제대로 작동하지 않거나 올바르게 작동합니다.PHPMailer 내가 Gmail의 SMTP 포트와 6.0.2</strong> LOCALHOST</strong><strong>에를 <strong>PHPMailer의 최신 버전을 사용하고 로컬 호스트
"SMTP 오류 : SMTP 호스트에 연결할 수 없습니다."오류를 반환하며 때로는 465 또는 587 포트에서 반환합니다.
은 지금은 여기에 587
포트 587에 대한 정확한 오류에이다; 여기
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
은 관련 코드입니다 : 마지막으로
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>";
}
}
TLS 오류입니다. 문제를 진단하고 해결하는 방법에 대한 오류 링크는 문제 해결 안내서에 나와있는대로 읽고 수행하십시오. – Synchro
감사! 조금 더 안내 할 수 있니? –
오류 메시지의 링크를 따라 가면서 말합니다. – Synchro