fuel/docs

can't catch exception at email package when time out.

Closed this issue · 2 comments

In my local environment,the reason I didn't set up properly, so smtp connection went to time out.

But I couldn't catch this as EmailSendingFailedException, it made just an error, showed an error page.


Error!

ErrorException [ Error ]: Maximum execution time of 30 seconds exceeded
PKGPATH/email/classes/email/driver/smtp.php @ line 215

210 */
211 protected function smtp_get_response()
212 {
213 $data = '';
214
215 while($str = fgets($this->smtp_connection, 512))
216 {
217 $data .= $str;
218
219 if (substr($str, 3, 1) === ' ')
220 {


My code is like :

                $email = Email::forge();
                $email->from('dummy@gmail.com', 'Site Adoministrator');
                $email->to($val->validated('email'), $val->validated('username'));
                $email->subject(__('confirm subject'));

                // making mail content.....


                Log::debug($content);
                $email->body($content);
                $mail_error = false;
                try {
                    $email->send();
                }
                catch (\EmailValidationFailedException $e) {
                    Session::set_flash('error', __('unable create mail'));
                    Auth::instance()->delete_user($val->validated('username'));
                    $mail_error = true;
                }
                catch (\EmailSendingFailedException $e) {
                    Session::set_flash('error', __('unable create mail'));
                   Auth::instance()->delete_user($val->validated('username'));
                    $mail_error = true;
                }

I did typical handling for user registration. And my code work well on real server. (On real server, email setting is perfect, because it is shard server. ;) )

And I hope to catch any 'failed to send email' situation by EmailSendingFailedException. Absolutely time out also.

This is not an exception, it's a PHP fatal error, which can't be caught.

aha, thx.