-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
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 time limit ($Timeout) fails if server is not responding at all #604
Comments
Unfortunately that would result in a massive performance hit. That |
Hello,
it does. I spent a whole day on tracking it down to this point :) I do not exactly know the background, but under some circumstances (possibly, if no data is received at all) I also was unhappy with the performance reduction... I tried with shorter usleeps() - starting with 0 and increasing, but the Replace these lines... while (is_resource($this->smtp_conn) && !feof($this->smtp_conn)) {
$str = @fgets($this->smtp_conn, 515); With those ones: $selR = array($this->smtp_conn);
$selW = null;
while (is_resource($this->smtp_conn) && !feof($this->smtp_conn)) {
if (!stream_select($selR, $selW, $selW, $this->Timelimit)) {
$this->edebug(
'SMTP -> get_lines(): timed-out (' . $this->Timeout . ' sec)',
self::DEBUG_LOWLEVEL
);
break;
}
$str = @fgets($this->smtp_conn, 515); The |
By the way... here's the output (with the 2016-01-10 13:03:40 SERVER -> CLIENT: |
This seems a little strange overall. You can't even attempt to call STARTTLS until you have connected. Do you mean you're using a traditional SMTPS ( The 300 sec default timeout is an RFC requirement, and I frequently see Yahoo servers waiting over 2 minutes before saying responding. If you're submitting via SMTP during a page load, this obviously gets in the way, but unfortunately that's the nature of SMTP - it's just not much good for anything real-time, so you need to hand off the transaction to something async, like a cron job. |
As far as I can see, the connection is created (in the logfile you see that there's a BYE response that does not stem from the PHPMailer, if I interpret this correctly?), but while the server expects TLS, some plain data is sent (no SSL or TLS). I do not exactly understand why the server ceases communication, maybe it's just waiting for further input.
Good point. I read through the note twice, and can follow the argument (I hope). It says that - when set to blocking (which it is) than the stream operation will be completed before anything else is done. As Regarding the $Timelimit: There's nothing wrong with the RFC ... well except that SMTP is somewhat outdated. I just thought that, if there is a function SMTP::setTimeout() than it may be sensible that this function does not only change $Timeout, but $Timelimit as well. Just in case, the $Timeout is set to a smaller value than $Timelimit. But possibly, I just messed up the meaning of $Timeout and $Timelimit. You probably know better which it the correct variable to be used in Of course, one should not use SMTP when loading a page. In my case it was a cronjob - but if the cronjob is killed after 1 hour due to a failed SMTP-connection (leaving later stuff in the cronjob undone), this still is a problem. Here's my trial of convincing you: Currently, under special circumstances, the $Timeout in the SMTP module seems to fail. If |
I think this sounds like a PHP bug since I don't see anything to suggest that Another workaround (and what I'd recommend anyway) is to submit to a local mail server. That way you should never have timeout issues and you don't need to worry about cron running into trouble either. BTW |
Hi, I had the issue with PHP 5.5.9 (should be the latest stable). Possible, it's still the "old" bug ... the bug report's status is still "open". Why should anyone fix the bug: The original cause still is the counterpart server ... easy to fix, usually ;)
Unfortunately, this is not an option in our software. Different users may specify "their own" SMTP servers - and these are usually not local... I am aware that this is not the intended use :) Btw.: A local SMTP may also fail. Imagine an update of the mailserver that changes it's response behavior... Even if it's only a PHP bug, I'd still argue that Thanks for the explanations regarding $Timeout and $Timelimit. $Timeout would be the appropriate variable for |
I've made this change in the 6.0 branch - thanks for all your input and testing. |
2019-05-30 19:34:44 SERVER -> CLIENT: 250 2.0.0 Ok: queued as CD341CC950 Email works fine .. no issue but displaying the client server time is not according to Indian Standard Time (IST). According to above code the time is different from IST . Actually below is the current time. How to Change the time to IST of client server in debugging... |
Debug times are all UTC. You can change that by injecting your own debug output handler, but I would suggest you don’t bother. When debugging SMTP you’re usually only looking at the seconds anyway. |
I had a hard day with an SMTP issue... Although the PHPMailer::$Timeout was set to 30 (does not matter which value) SMTP::get_lines() hung for a very long time (30-60 minutes). I run on an up-to-date Linux system (Ubuntu VPS, nginx, php5-pfm).
A plausible explanation was that the SMTP server does not send anything, which can cause stream_set_timeout() to be effectless. Here's is a suggestion how to modify SMTP::get_lines() to solve the issue - at least on a Linux system.
Replace the following line:
by the following block:
I'd like to state explicitly that I am an expert neither on SMTP nor on non-blocking file operations. This is a practitioners solution that seems to work quite well.
The text was updated successfully, but these errors were encountered: