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

Handling SMTP errors on user creation #552

Closed
alexweissman opened this issue Jun 5, 2016 · 11 comments
Closed

Handling SMTP errors on user creation #552

alexweissman opened this issue Jun 5, 2016 · 11 comments
Labels
confirmed bug Something isn't working mail Email related

Comments

@alexweissman
Copy link
Member

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.

@Netrilix Netrilix added the confirmed bug Something isn't working label Jun 7, 2016
@Netrilix
Copy link
Contributor

Netrilix commented Jun 7, 2016

By hung, do you mean 500 error and white page? If so, I can confirm this.

My error log shows the following:
[07-Jun-2016 16:46:34 America/New_York] Mailer Error: <strong>SMTP Error: Could not authenticate.</strong><br />

@alexweissman
Copy link
Member Author

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?

@Netrilix
Copy link
Contributor

Netrilix commented Jun 7, 2016

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).

@alexweissman
Copy link
Member Author

Actually, even cPanel hosts support cron. So, maybe it wouldn't be so bad if we split it off into a cron script?

@Netrilix
Copy link
Contributor

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.

@frostbitten
Copy link
Contributor

frostbitten commented Jun 29, 2016

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

@Netrilix
Copy link
Contributor

Cron with fallback would alleviate my concerns, I'd say let's go with it.

@alexweissman
Copy link
Member Author

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 cron.

@alexweissman alexweissman added the mail Email related label Aug 20, 2016
@Silic0nS0ldier
Copy link
Member

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.

@lcharette
Copy link
Member

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

@lcharette lcharette added this to the 4.4.0 milestone Oct 28, 2018
@lcharette
Copy link
Member

Duplicate of #763.

@lcharette lcharette removed this from the 4.4.0 milestone Jan 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
confirmed bug Something isn't working mail Email related
Projects
None yet
Development

No branches or pull requests

5 participants