Avoid a timeout after sending a mass mail

By: Lacombe Alexandre | Asked: 09/25/2022
ForumsCategory: Code HelpAvoid a timeout after sending a mass mail
Lacombe Alexandre asked 2 years ago

Hi there ! :) 

I'm using a form action that sends an email when an entry is created.

I have a very very large mailing list in my recipient area and I am using the following function:

https://formidableforms.com/knowledgebase/frm_send_separate_emails/

The problem is that when I create an entry, there are so many recipient emails that it generates a timeout after 20-30 minutes. Do you have a solution for the action to launch via the server and not via my browser session? Or how to avoid the timeout?

Thank you very much and have a nice day !

5 Answers
Victor Font answered 2 years ago

Many hosts prohibit launching bulk emails from within WordPress because of the load it places on server processes, especially if you're on a shared host. They often meter the rate of emails to 100/day or a small number per hour. If you have such a huge recipient list, why wouldn't you consider using a marketing platform like Active Campaign or something similar?

Lacombe Alexandre replied 2 years ago

Hi !

Yes indeed, I manage the customer base of 50k on formidable form but I send with a Sendgrid smtp server.

Lacombe Alexandre replied 2 years ago

<p>The problem of sending emails suddenly is not a concern. Sendgrid handles well. It is only the timeout of the function which transforms the list into a single mail which poses a problem. The moment I click "Create Entry"</p>

Lacombe Alexandre answered 2 years ago
An exemple of my action.
Attachments
Victor Font replied 2 years ago

I suggest you contact your host and see if they'll permit you to raise the PHP timeout. You may also be able to increase the PHP timeout in cPanel. If you're on a shared server, don't be surprised if the host says no.

Lacombe Alexandre replied 2 years ago

I'm at O2SWITCH, I was able to change the timeout from php.ini but it still causes a timeout, I don't understand. Can I send you an example of my php.ini to help?

Victor Font replied 2 years ago

You need to contact your host for help with adjusting the timeout with PHP. There are two reasons for which you may be experiencing a timeout:

Exhausted PHP memory limit or maximum execution time is set too low. Your host (O2SWITCH) should help you. Open a support ticket with them. The issue is not with Formidable Forms. It's because of your choice to send emails to a 50k long mailing list from within WordPress without having benchmark timings for your server. How long does your server take to process 50k records in one chunk? Your maximum execution time needs to exceed the baseline and your PHP/WordPress memory limit must be large enough to handle the request.

This requires access to your server. As community volunteers, we can't assist with that level of troubleshooting without accepting the job as a paid project. Contact your host for server setup assistance.

Lacombe Alexandre answered 2 years ago
We wouldn't have a timeout problem if it was the server that launched the form action and not the browser. Do you have an idea to do that? I know that the automation module launches actions in this way.
Victor Font replied 2 years ago

The browser does not launch form actions. Form actions are server functions and run through PHP via the submit. Browsers cannot execute PHP, only servers can.

Lacombe Alexandre replied 2 years ago

Ha okay so the timeout would come from where? This happens when I create an entry (this problem has been present since I put the separation function)

Victor Font replied 2 years ago

I don't know what you mean by "since I put the separation function". Contact O2SWITCH for further assistance with configuring PHP. I'm closing this thread to further comment.

Lacombe Alexandre answered 2 years ago
There is indeed a timeout which is set by the server, I just called them.

So I do not have the hand to increase it. The timeout appears since I use the frm_send_separate_emails function, do you have any idea how to optimize this one to avoid that it loads on the browser side?
Victor Font replied 2 years ago

You cannot execute a form action in the browser. What you want to do is not technologically possible. Form actions are server processes only. If you can’t set the timeout on your server, change hosts or trigger the emails to be sent from a tool that is designed for mass emails like Active Campaign.

Lacombe Alexandre replied 2 years ago

I really have the impression that you have not read everything I have indicated... I will perhaps wait for another person to answer me because I am repeating myself. Thanks anyway 🙂

Victor Font replied 2 years ago

I've read everything you said. What you want to do cannot be done. It is not feasible. You are asking to send emails that can only be sent from your server directly from your client browsers. Not only would you be stealing your client's bandwidth if it were feasible at all, but Form Actions can only be executed on the server because they are PHP processes. They cannot be executed in the browser.

I'm sorry you haven't received the answer you want. The answer is the right answer though for the problem you're trying to solve as you've described it. I shared your alternatives with you. You cannot execute form actions in the browser. It's not possible. If you wait for someone else to tell you something different, you'll be waiting for a very long time. Good luck.

Lacombe Alexandre replied 2 years ago

As indicated, the mails are sent by Sendgrid. I use the formidable form SMTP module which sends mails directly from the sendgrid servers.
What currently poses a problem are not the actions but the script that I sent you several times (the one that transforms a list into a single email). The problem is that this function creates a timeout on my browser, the actions are not in question but the function of the formidable form documentation.

Victor Font replied 2 years ago

It doesn't matter that you are using sendgrid. That's not relevant to your problem You have a server timeout issue while executing a PHP script while processing a 50k mailing list. This can ONLY BE FIXED by changing the server timeout. If you can't change the server timeout, find a new host where you have more control over the server, or upload the entire mailing list to a tool designed to handle mailing lists like Active Campaign and where you can sort them by tags automatically. Sendgrid is not going to help you. It is a transactional email system, not a campaign system. You are not going to get a different answer from anyone else.

Bobby Clapp answered 2 years ago

Agreeing with Victor. Some articles on the subject: Email Options

In practice with typical technology security standards, you or your host would likely be marked as a spammer if you were able to send out some mass amount of emails at once. It's just not how it works.

Making the Best WordPress Plugin even better - Together

Take on bigger projects with confidence knowing you have access to an entire community of Formidable Experts and Professionals who have your back when the going gets tough. You got this!
Join the community
crossarrow-right