• Resolved ve3meo

    (@ve3meo)


    I’m using FluentSMTP on a shared hosting website with Asgaros Forum plugin and a custom function to send Announcements to all registered users via two Gmail API connections, one is Backup for failover. I’ve run into issues with the sending rate exceeding the API limit and with the FluentSMTP log missing both Sent successes and errors. And there is a limit of 120-300s by the webhost on PHP worker duration that requires batched requests. It looks like we want to send no faster than every 3s in batches of up to 10 or 20 with a 5s rest between batches to start a fresh worker for each batch.

    • Is Mail Queue compatible with FluentSMTP?
    • Are the parameters send_rate (or send_interval), batch_size (or queue_size) and queue_interval accessible through your Settings and can they support the values cited above?
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support wdmnicolas

    (@wdmnicolas)

    Hi @ve3meo,

    Mail Queue doesn’t change how emails are sent. It hooks into WordPress’ standard pre_wp_mail filter to store each email, and later passes it back to wp_mail() for the actual sending. So in theory it should work with any mailer plugin that sticks to the standard wp_mail() flow, FluentSMTP included. We haven’t tested that combination ourselves, so we can’t guarantee it, and things like FluentSMTP’s failover are entirely up to FluentSMTP.

    Rate settings: The Mail Queue settings has one rule: “Send max. [N] email(s) every [X] minutes/seconds”.

    • N (batch size) can be any number.
    • The interval is at least 10 seconds.
    • The emails within one batch go out one after another, with no pause in between. There is no per-email delay. So “one email every 3 seconds” isn’t possible.
    • Each batch runs in its own cron request, so each batch gets a fresh PHP worker.

    Our recommendation: for announcements, go slower than you planned. For example 2-5 emails every minute. Your announcement then takes a few hours instead of minutes, but you stay well clear of your host’s worker limit and the Gmail API rate limits. Google also has daily sending limits per account, and at one email every few seconds you’d reach them quickly on a larger user list.

    Two more notes:

    1. WP-Cron only runs when someone visits the site. For a steady interval, set DISABLE_WP_CRON and call wp-cron.php from a real cron job.
    2. Mail Queue logs every email as sent or failed. If the mailer plugin reports a failure without details, we only show a generic error, and the actual reason is then in the mailer’s own log. There is no automatic retry, but failed emails can be resent manually from the list.

    Hope that helps!

    Kind regards,
    Nicolas

    Thread Starter ve3meo

    (@ve3meo)

    Thanks for the quick reply, Nicolas.

    My concern with FluentSMTP logging not keeping up is that the same failure may occur with it sending fail messages back to Queue so its logging and reactions would also be spotty. Would this setting work in Queue?: 1 email every 10s.
    Given a user population of 400, that would send ~6 per minute with 10s between each email which should allow time for all processes to complete for each email, respect Gmail API’s rate limit (6/min is well below the estimated max of 50-60/min), respect the host’s max PHP worker time (10s << 120-300s) and complete in <70 min.

    I’m unconcerned about Gmail’s limit of 500 sends/24 hours. Our forum is pretty quiet and we have a backup Gmail to which FluentSMTP successfully did a failover. I’m also working on getting Amazon SES as a backup on a pay per use basis – I assume that Queue cannot switch to a different Rate Setting based on what connection FluentSMTP is using.

    Re the CRON tickle: what frequency should that be? We had ~80 page views yesterday. As I understand it, each one of those would trigger Queue to run through all existing batches and any added while it’s still sending. Is that correct? So should the CRON tickle be hourly or every minute or just daily?

    Plugin Support wdmnicolas

    (@wdmnicolas)

    Hi @ve3meo

    yes, “1 email every 10 seconds” is a valid setting. But there is a WordPress limitation you need to know about before you rely on the 10 seconds:

    WordPress core only lets wp-cron.php run once per minute (WP_CRON_LOCK_TIMEOUT, default 60 seconds). That applies to visitor-triggered cron and to external cron jobs alike, and calling wp-cron.php more often doesn’t help on its own, since the lock isn’t released after a run, it only expires. Mail Queue sends one batch per cron run, so with “1 email every 10 seconds” you’d actually get about 1 email per minute. For 400 users that means roughly 7 hours for the whole announcement. If that’s acceptable, you’re done: set 1 email every 10 seconds (or simply every 1 minute, which is the same in practice) and let it run.

    If you really want 6 per minute with a 10-second gap, you need both of these:

    1. define( 'WP_CRON_LOCK_TIMEOUT', 10 ); in wp-config.php
    2. a cron job that calls wp-cron.php every 10 seconds (plus DISABLE_WP_CRON), which most shared hosts and cron services don’t offer at that frequency

    The alternative within the 1-minute limit is “6 emails every 1 minute”. Those 6 go out back to back within one PHP run, which is still a short request, but without the 10-second gap you asked for.

    On your logging concern: Mail Queue doesn’t depend on the mailer plugin’s log. It calls wp_mail() and records the success/failure that call returns, in the same request. So its status is complete even if the mailer’s own log isn’t. The only gap is error details: if the mailer reports a failure without a message, we show a generic error.

    One more thought. Most of what you’re working around comes from sending bulk mail through Gmail. Gmail’s API limits are made for a personal mailbox, not for announcements to 400 people. A transactional email service (Postmark, Amazon SES, Mailgun, SendGrid, …) has no per-minute limits in your range, handles retries and bounces for you, and makes the backup connection unnecessary. FluentSMTP already offers these as connection types, so you’d only swap the connection, not the plugin. With that in place, Mail Queue at a relaxed rate (say 5-10 per minute) is purely a safety net against PHP timeouts. If the site keeps growing, a small VPS instead of shared hosting would also remove the worker-time limit, but I’d start with the mail service, it’s the cheaper and bigger win.

Viewing 3 replies - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.