Welcome Guest, Not a member yet? Register   Sign In
Email Timeout
#1
Question 

I've recently happened across a situation with Email Timeouts that appears to have no simple work-around.

Although the Email setup I have generally works well, in certain situations I've found that if the connection to the SMTP server is lost/broken, or, in this particular case, the SMTP server purposefully silently doping the connection (as s a result of the SMTP being subject to excessive attacks by spammers, the owners of the server purposefully leave certain connections hanging))... it causes the CI code to wait pretty much indefinable (in my case long enough to have the (generous) JavaScript timeout on the client side terminate the connection with a "the server's not responding" error message
.
In the Email config, I have:

Code:
public int $SMTPTimeout = 5;
public bool $DSN = true;            // since this SMTP server does advertise DSN

It would appear that $SMTPTimeout only applies to the initial establishment of the connection/stream, but once there has been some handshaking... its job is done and never gets used again.

Is there any reasonable way to be able to have some sort of timeout on the connection's total duration... so that, say once the connection has been established (within $SMTPTimeout), some other timer starts ticking, so that within say $SMTPMaxDuration, if the interaction hasn't been concluded, CI assumes that it's the connection has fallen over/failed... and then returns control/a failure notification?

I have sniffed around in the protected function sendData($data), in system/Email/Email.php, which makes it evident that $result ( ===0 ) is necessary before the code uses $SMTPTimeout... whereas the timeout should likely be applied in the fwrite() function that generates this $result.  A superficial look at PHP like stream_set_timeout() also don't seem to be a quick fix (as it also appears to work on stream establishment and not as an end-stop for the maximum duration.

Any ideas or suggestions would be appreciated, thanks.
Reply
#2

Did you try using PHPMail to see if it times out?
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

(This post was last modified: 01-21-2024, 09:14 AM by Gary.)

InsiteFXDid you try using PHPMail to see if it times out?

Thanks InsiteFX.

This would mean setting $protocol = 'mail'... vs 'smtp' that I've had it on?

I've not been able to find any details about this 'mail' protocol in the CI documentation, even though this is the default (preferred ?) protocol used by CI... so I've not experimented extensively with it.  I have tried it... and it seem to result in a success send message almost immediately (on the webpage sending the message) for every attempt at sending an email (even to no-existent user email addresses).  The email does appear to arrive when there is a legitimate email address (and, of course, not if there isn't one).  Strangely enough, in the CI log file (even when there was a genuinely successful send), there appears to be a failure reported in the CI log file:

Code:
ERROR - 2024-01-21 14:08:33 --> Email: Unable to send email using PHP mail(). Your server might not be configured to send mail using this method.

Would you know where I could look for more details on the 'mail' protocol?
Reply
#4

Sorry I meant PHPMailer which is an Email Library that a lot of use in CodeIgniter.

PHPMailer – A full-featured email creation and transfer class for PHP

How to send an email using PHPMailer ?
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#5

(01-21-2024, 10:27 AM)InsiteFX Wrote: Sorry I meant PHPMailer which is an Email Library that a lot of use in CodeIgniter.

Thanks for the links InsiteFX.

No, I've not tried PHPMailer yet... but it certainly looks more fully-featured than what I've been using with the 'smtp' protocol (that CI uses PHP's fwrite() for, from what I can make out), and quite easy to use too.  The email functionality is very limited in my particular application, but I still think it will probably be worth adding to the list of intended revisions to be made, thank you.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB