1
AWS에서 PHPMailer를 설정하려고합니다. SMTP connect()에 오류가 발생합니다.PHPMailer SMTP 연결 오류
코드
<?php
require 'vendor/autoload.php';
$mail = new PHPMailer;
$mail->isSMTP();
$mail->SMTPDebug =2;
$mail->Debugoutput = 'html';
$mail->Host = 'smtp.gmail.com';
$mail->Port = 587;
$mail->SMTPSecure = 'tls';
$mail->SMTPAuth = true;
$mail->AuthType = 'XOAUTH2';
$mail->oauthUserEmail = "[email protected]";
$mail->oauthClientId = "client-key.apps.googleusercontent.com";
$mail->oauthClientSecret = "secretkey";
$mail->oauthRefreshToken = "refresh_token";
$mail->setFrom('[email protected]', 'ParkIt');
$mail->addAddress("[email protected]", "Tittu Varghese");
$mail->Subject = 'ParkIt - Verification Code';
$mail->Body = 'Please verify your account';
$mail->send();
if (!$mail->send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}
?>
디버그 로그
SERVER -> CLIENT: 220 smtp.gmail.com ESMTP 22sm11056028qkv.52 - gsmtp
CLIENT -> SERVER: EHLO server_domain_or_ip
SERVER -> CLIENT: 250-smtp.gmail.com at your service, [54.157.255.58]250-SIZE 35882577250-8BITMIME250-STARTTLS250-ENHANCEDSTATUSCODES250-PIPELINING250-CHUNKING250 SMTPUTF8
CLIENT -> SERVER: STARTTLS
SERVER -> CLIENT: 220 2.0.0 Ready to start TLS
CLIENT -> SERVER: EHLO server_domain_or_ip
SERVER -> CLIENT: 250-smtp.gmail.com at your service, [54.157.255.58]250-SIZE 35882577250-8BITMIME250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH250-ENHANCEDSTATUSCODES250-PIPELINING250-CHUNKING250 SMTPUTF8
SMTP Error: Could not authenticate.
CLIENT -> SERVER: QUIT
SERVER -> CLIENT: 221 2.0.0 closing connection 22sm11056028qkv.52 - gsmtp
SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
SERVER -> CLIENT: 220 smtp.gmail.com ESMTP s191sm6833675qke.56 - gsmtp
CLIENT -> SERVER: EHLO server_domain_or_ip
SERVER -> CLIENT: 250-smtp.gmail.com at your service, [54.157.255.58]250-SIZE 35882577250-8BITMIME250-STARTTLS250-ENHANCEDSTATUSCODES250-PIPELINING250-CHUNKING250 SMTPUTF8
CLIENT -> SERVER: STARTTLS
SERVER -> CLIENT: 220 2.0.0 Ready to start TLS
CLIENT -> SERVER: EHLO server_domain_or_ip
SERVER -> CLIENT: 250-smtp.gmail.com at your service, [54.157.255.58]250-SIZE 35882577250-8BITMIME250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH250-ENHANCEDSTATUSCODES250-PIPELINING250-CHUNKING250 SMTPUTF8
SMTP Error: Could not authenticate.
CLIENT -> SERVER: QUIT
SERVER -> CLIENT: 221 2.0.0 closing connection s191sm6833675qke.56 - gsmtp
SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
Mailer Error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
오류 로그에 'SMTP 오류 : 인증 할 수 없음'이 표시됩니다. 올바른 자격 증명을 설정 했습니까? – Justinas
[PHPMailer 위키의 Google xoauth2 가이드] (https://github.com/PHPMailer/PHPMailer/wiki/Using-Gmail-with-XOAUTH2)를 사용해 보았습니까? – Synchro