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

Connection hangs at "get_lines()" #2907

Closed
6 tasks done
GregJohnStewart opened this issue May 12, 2023 · 2 comments
Closed
6 tasks done

Connection hangs at "get_lines()" #2907

GregJohnStewart opened this issue May 12, 2023 · 2 comments

Comments

@GregJohnStewart
Copy link

GregJohnStewart commented May 12, 2023

Please check these things before submitting your issue:

  • Read the error message you're seeing - it often tells you what is wrong, and may contain useful links & instructions
  • Make sure you're using the latest version of PHPMailer
  • Check that your problem is not dealt with in the troubleshooting guide, especially if you're having problems connecting to Gmail or GoDaddy
  • Include sufficient code to reproduce your problem
  • If you're having an SMTP issue, include the debug output generated with SMTPDebug = 2 set
  • If you have a question about how to use PHPMailer (rather than reporting a bug in it), tag a question on Stack Overflow with phpmailer, but search first!

Problem description

Setting up emailing for the first time, and when I call send(), it hangs until the timeout is reached.

I have verified that I can reach my mail server's host/port from Thunderbird on the same machine, using the same settings and credentials.

Code to reproduce

$mail = new PHPMailer;
$mail->isSMTP();
$mail->SMTPAuth = true;
$mail->SMTPDebug = SMTP::DEBUG_LOWLEVEL;
$mail->Host = Context::$CONTEXT['email']['host'];
$mail->Port = Context::$CONTEXT['email']['port'];
$mail->Username = Context::$CONTEXT['email']['username'];
$mail->Password = Context::$CONTEXT['email']['password'];

$mailer->addAddress($recipientEmail, $recipientName);
$mailer->setFrom(Context::$CONTEXT['email']['username'], $name);
$mailer->addCC($email, $name);
$mailer->isHTML(true);
$mailer->Body = $mailBody;
if(!$mailer->send()){
//...

Debug output

2023-05-12 03:04:04 Connection: opening to mail.myhost.com:465, timeout=300, options=array()
2023-05-12 03:04:04 Connection: opened
2023-05-12 03:09:04 SMTP -> get_lines(): select timed-out in (300 sec)
2023-05-12 03:09:04 SERVER -> CLIENT:
2023-05-12 03:09:04 Connection: closing due to error
2023-05-12 03:09:04 Connection: closed
@Synchro
Copy link
Member

Synchro commented May 12, 2023

This looks like a misbehaving server. SMTP spec says servers have to respond within the timeout period, but it seems yours is not. What happened when you tried the openssl tests described in the troubleshooting guide? It could be an issue with TLS config, but problems on port 465 are harder to diagnose than using port 587, so give that a try and see if it behaves differently.

@GregJohnStewart
Copy link
Author

Thanks! Somehow missed the section with SMTPSecure = PHPMailer::ENCRYPTION_SMTPS, that's what fixed it.

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

2 participants