XF 2.0 Email sending limits

CMTV

Well-known member
Hi!

I am sending an emails to all email-subscribed thread watchers:
PHP:
if($watcher->email_subscribe)
{
    $mailParams = [
        'solver' => $actionCaller,
        'thread' => $thread,
        'forum' => $thread->Forum
    ];

    \XF::app()->mailer()->newMail()
        ->setToUser($watcherUser)
        ->setTemplate('questionthreads_unsolved', $mailParams)
        ->send();
}

Theoretically there can be a lot of watchers... 10, 20, 100...
I know there are some limits on sending email really frequent. Some bad things may occur when going beyond the limit.

Is keeping sending in limits is done automatically in xF or I need to separate all watchers on small groups and send emails with time delay? And if so what is the best way to send a lot of emails?
 
Last edited:
There isn't any automatic throttling on mail sending. If you have a lot of mail to send, you would likely want to push it into a job and send them in batches to avoid timeouts. We do this for watch notifications, though that code is likely more complex than you necessarily need. The user email sending system used in the ACP uses a job as well so that might give you some ideas.
 
Back
Top Bottom