-2

我在 cron 中创建了一个函数,通过 wp_mail() 发送大约 250 封电子邮件。但是,我的托管服务提供商不允许每小时发送超过 50 封电子邮件。有没有办法强制 wordpress 缓存所有电子邮件并每小时发送 50 封?

谢谢!

4

2 回答 2

1

Here's the Logic you can follow:

  • When you want to trigger 250 Emails then call a function to save all 250 emails in the array format. An Email Array which will include Email ID, Email Subject, Email Content, Headers if any, etc.
  • Create server-side CRON to run every 5 mins.
  • Server CRON will go to settings and fetch OLDEST 50 email which will be deleted from the settings as well. That means if we have 250 emails then we will be left with 200 emails in the settings.
  • Next, Server CRON will simply call the wp_email function and send 50 emails successfully.
  • Likewise, it will keep sending emails until all the emails from the settings are empty.

I hope that makes sense. Thanks.

于 2019-11-25T12:51:22.917 回答
0

You can create a new table named like tasklist then put all "to send" emails in it and write your cronjob to run 50 of these entries for every hour. Put a flag column to table to mark which one is send and set your script to send the not flagged ones.

于 2019-11-25T12:49:46.543 回答