-
-
Notifications
You must be signed in to change notification settings - Fork 367
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
Handling SMTP errors on user creation #552
Comments
By hung, do you mean 500 error and white page? If so, I can confirm this. My error log shows the following: |
not even a white page actually, because (on my server at least), it literally had to wait until the script timed out and returned the error response. Maybe there is a way to manually set the SMTP timeout in PHPMailer? |
Oh, two different issues. Mine connected to the server but I provided an incorrect password (which gives a while screen with no explanation). Yours was waiting to time out connecting to the server, which is also not great. Ideally, e-mail would be sent out by a background process and not on the user's time, but that tends to be server-specific (cron, etc). |
Actually, even cPanel hosts support cron. So, maybe it wouldn't be so bad if we split it off into a cron script? |
I love cron, but I think it might be overkill to require it as part of UF. Not to mention a lot of our users are on Windows, and Task Scheduler is just awful. We could investigate a PHP task queue, but they all require a daemon running on the back end to read and execute the tasks. Here's an alternative idea: What if we used ajax for the limited amount of mail we send? The page can finish loading, and then the ajax can call the e-mailing script and return either a "mail sent successfully" or "sending mail failed" message to the page. It'll eliminate the user getting "page loading" while the e-mail is being sent, and we can handle the errors directly in the controller code. |
I too have been thinking about how we can best do things like send emails where there might be an error and a retry is in order. This does sound like a job for cron. The alternative proposed by @Netrilix is interesting and a nice shim for cron-like operations. I would prefer a cron based approach with some fallback, possibly the ajax method, or some php library that does cron-like jobs each time the app runs. As for windows users not able to use cron, it can indeed be a bit difficult to do automated tasks. Luckily for me, the wamp stack I use has a built in cron tool. I'm assuming that most of our windows users are just developing. For them, using a basic cron tool like the one built into UniServer shouldn't be a big concern. If they are actually deploying on windows then shouldn't they know how to set up the appropriate task scheduler? Seems to be a trivial extra step to the experienced developer and a good learning opportunity to those who are new |
Cron with fallback would alleviate my concerns, I'd say let's go with it. |
Ok. I'm going to label this as low-priority, but something we should consider once v4 settles out. I think this could be an admin setting, with the default "Send immediately" using a separate AJAX request as per @Netrilix's suggestion. The other option "Send on a schedule" would use |
Delay aside (I think PHPMailer is simply slow when denied permission, or perhaps has retry logic. Ah heck, every SMTP client I've used is slow to respond when the details are incorrect! Could be by design for all I know!), I think the error is being caught. Considering that as of d09de83 its got an error handler that successfully triggers. |
Saving this reference so I don't search for it later. Could be useful to delayed email delivery or saving to file : https://stackoverflow.com/questions/23212634/php-mailer-compile-and-store-message-for-later-sending |
Duplicate of #763. |
I tried to create a new user from the admin panel on a fresh install with incorrect SMTP credentials, and the site just hung. I think for whatever reason, that error wasn't being caught and dealt with appropriately.
The text was updated successfully, but these errors were encountered: