verbb / formie

The most user-friendly forms plugin for Craft CMS.
Other
96 stars 72 forks source link

E-mail notifications sent in batches (whenever I visit control panel?) #709

Closed nitech closed 2 years ago

nitech commented 2 years ago

Description E-mail notifications for submissions are not sent immediately but rather in batches whenever I visit the control panel.

For instance, one of the emails received on 2022-01-10 12:49 was in submitted on 2022-01-09 18:34:22.

I assume the problem is the queue not being processed. I did some googling and found that I am supposed to set 'runQueueAutomatically' => true, - which was already set correctly.

What else do I need to change so the notifications gets sent immediately?

Form settings

Additional info

engram-design commented 2 years ago

We use Craft’s queue system to send out email notifications and run integration tasks. This is so that they don’t hold up form submission for users, which we’ve found particularly for SMTP-based email providers, this can be incredibly slow (sometimes 5-10 seconds), and likewise with API integrations (Mailgun, Sendgrid, etc). So for the best customer experience, we’ve opted to send these out via the queue.

Can you let me know if you have queue-processing setup for your queue? If not, have a read through through https://nystudio107.com/blog/robust-queue-job-handling-in-craft-cms. The default behaviour for Craft is to only run the queue when the control panel is visited which seems exactly what's going on here. I would advise you to setup proper queue running through one of the options Andrew mentions in his article above. This is probably a good idea, generally. Even Commerce (which you might not be using) has this same issue, where order emails are sent out via the queue - again to improve performance when going through checkout (significantly I might add).

And you can certainly turn this off. The useQueueForNotifications plugin setting or in the Formie > Settings area controls this. This way, emails will be sent as soon as the user submits the form, but in the same process, which as I’ve stated above might lead to delays.

For more information see https://verbb.io/craft-plugins/formie/docs/feature-tour/email-notifications#sending-emails where we explain this behaviour.

nitech commented 2 years ago

I believe you're spot on. I'll try this and get back if I have further questions. Thanks.

darylknight commented 1 year ago

Landed here after a client emailed us yesterday to say they received 10 form notifications in one day, all from over the past week. I didn't expect it to be Craft / Formie related and went digging around in their SMTP provider logs. They don't visit the control panel that often, so the notifications don't get sent.

While I understand the reasoning behind this reading your reply above, I have to say coming from Freeform - it didn't have this issue and I'm pretty surprised to discover this is how Formie is set up by default. I believe if you install a form plugin, you would expect notifications to be sent when the form is submitted without any extra setup work. Could I suggest please that something is added prominently to the Formie docs to explain that you need to set up a queue runner for this to function as expected, or that you need to disable "useQueueForNotifications"?

engram-design commented 1 year ago

I believe if you install a form plugin, you would expect notifications to be sent when the form is submitted without any extra setup work

I certainly appreciate that opinion and reasoning, but I also can appreciate complaints from customers and clients on slow form submissions, which leads to a poor UX. Depending on the form use-case, this can lead to lost interest from end-users, or a lack of

I understand it's a change coming from Freeform, but it's been in place since Formie was released. As for the docs, It's mentioned 3 times, in the areas that you'd expect (more when referring to integrations):

https://verbb.io/craft-plugins/formie/docs/feature-tour/email-notifications https://verbb.io/craft-plugins/formie/docs/get-started/troubleshooting

This will also be a little easier for users in Craft 5 (or 6) with a proper and robust scheduler built into Craft, to prevent the need of visiting the control panel to process the queue. I think in general, Craft should probably promote a better queue-processing mechanism in general, not just for Formie, rather than relying on visiting the control panel for all manner of tasks (search indexes, image transforms, etc).