Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SMTP connect() failed. #2695

Closed
fangerpl opened this issue Jun 8, 2022 · 2 comments
Closed

SMTP connect() failed. #2695

fangerpl opened this issue Jun 8, 2022 · 2 comments

Comments

@fangerpl
Copy link

fangerpl commented Jun 8, 2022

from yesterday im getting this errors when i trying to send emails via mailer

Code:

use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;

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

$mail = new PHPMailer;
$mail->isSMTP();
$mail->SMTPDebug = 0;
$mail->Host = "smtp.gmail.com"; 
$mail->Port = 587; 
$mail->SMTPSecure = 'tls'; 
$mail->SMTPAuth = true;
$mail->Username = "xxx@mail.com"";
$mail->Password = "xxxpass";
$mail->setFrom("xxx@mail.com", "xxxx");
$mail->addAddress("xxx@email.com", "xxx");
$mail->Subject = 'subject';
$mail->msgHTML('message');
$mail->AltBody = 'HTML messaging not supported';

if($mail->Send())
{
	header('Location: /');
}
else
{
echo 'Mailer Error: ' . $mail->ErrorInfo;
}

Full output with client and server messages:

2022-06-08 18:32:18 SERVER -> CLIENT: 220 smtp.gmail.com ESMTP jg36-20020a170907972400b00701eb600df8sm10084156ejc.169 - gsmtp
2022-06-08 18:32:18 CLIENT -> SERVER: EHLO localhost
2022-06-08 18:32:18 SERVER -> CLIENT: 250-smtp.gmail.com at your service, [83.25.245.41]250-SIZE 35882577250-8BITMIME250-STARTTLS250-ENHANCEDSTATUSCODES250-PIPELINING250-CHUNKING250 SMTPUTF8
2022-06-08 18:32:18 CLIENT -> SERVER: STARTTLS
2022-06-08 18:32:18 SERVER -> CLIENT: 220 2.0.0 Ready to start TLS
2022-06-08 18:32:18 CLIENT -> SERVER: EHLO localhost
2022-06-08 18:32:18 SERVER -> CLIENT: 250-smtp.gmail.com at your service, [83.25.245.41]250-SIZE 35882577250-8BITMIME250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH250-ENHANCEDSTATUSCODES250-PIPELINING250-CHUNKING250 SMTPUTF8
2022-06-08 18:32:18 CLIENT -> SERVER: AUTH LOGIN
2022-06-08 18:32:18 SERVER -> CLIENT: 334 VXNlcm5hbWU6
2022-06-08 18:32:18 CLIENT -> SERVER: [credentials hidden]
2022-06-08 18:32:18 SERVER -> CLIENT: 334 UGFzc3dvcmQ6
2022-06-08 18:32:18 CLIENT -> SERVER: [credentials hidden]
2022-06-08 18:32:18 SERVER -> CLIENT: 535-5.7.8 Username and Password not accepted. Learn more at535 5.7.8 https://support.google.com/mail/?p=BadCredentials jg36-20020a170907972400b00701eb600df8sm10084156ejc.169 - gsmtp
2022-06-08 18:32:18 SMTP ERROR: Password command failed: 535-5.7.8 Username and Password not accepted. Learn more at535 5.7.8 https://support.google.com/mail/?p=BadCredentials jg36-20020a170907972400b00701eb600df8sm10084156ejc.169 - gsmtp
SMTP Error: Could not authenticate.
2022-06-08 18:32:18 CLIENT -> SERVER: QUIT
2022-06-08 18:32:18 SERVER -> CLIENT: 221 2.0.0 closing connection jg36-20020a170907972400b00701eb600df8sm10084156ejc.169 - gsmtp
SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

@ghost
Copy link

ghost commented Jun 9, 2022

Gude on how to use OAuth: https://github.com/PHPMailer/PHPMailer/wiki/Using-Gmail-with-XOAUTH2
Script to get a token: https://github.com/PHPMailer/PHPMailer/blob/master/get_oauth_token.php
Script to send an email: #2693 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants