1

On the SMTP module configuration page at /admin/config/system/smtp, it offers the option to Send mail by queue (Mails will be sent by drupal queue api.).

When would I want to check this box? What are the advantages and disadvantages?

6

TL;DR: send the email by queue if you are sending larger number of emails at once, or if your SMTP server takes longer time to process a request (for whatever reason).

Below is a brief overview of the main pros/cons.

Pros

  • Better handling of large volume of emails. Email sending task will be split into batches, and Drupal will process them in smaller chunks during cron runs. This is better because your server might time out or become unresponsive for visitors if you are trying to send 500 emails at once.
    If the same task is split into multiple batches, it will be easier to process them, and regular visitors will not experience as big decrease in performance.

Cons

  • Requires more frequent cron (or a custom script that will process the batches), which translates into more used resources at all times. You might see certain decrease in performance if the site is processing email batches and there are a lot of users online simultaneously. This of course depends on many factors (number of emails you are sending, frequency of your cron, speed at which remote SMTP server processes the requests, number of visitors on your site, complexity, and so on).
    See Elysia Cron module for fine tuning the cron implementations of all modules on your site. It will help you use less resources during each cron run, because you will be able to choose how often will cron of certain modules be run.

  • In some cases this can result in slower email delivery. If you have a large number of emails to deliver (e.g. 100k newsletter subscription list), last user in the queue will receive the message significantly later than the first one. Also, all emails requested to be sent during that time, will be delayed as well.

1

We also did this to control the rate of email flow.

As well our SMTP server is a little slow, and errors sometimes for an unknown reason during the authentication phase, upon which we would need to retry until the email sent. By using the queue the user doesn't have to wait, instead we return a confirmation screen to them immediately, and then let the smtp queue and retry errors on queue take care of sending the email later.

Note you don't need to run the whole cron, you can just run the command drush queue-run smtp_send_queue, and it should send your emails.

1

The previous two answers discuss the pros/cons of queuing email when sending large batches. There are different pros/cons when non-batch emails are sent (e.g. triggered by a user registration event).

The questioner doesnt say which version of the SMTP module they're using, but the current 8.x-1.0-beta3 doesnt have the option to queue (sadly). Nevertheless, the pros and cons of queuing that seem evident to me are:

Pros: If the SMTP server cannot be reached, for any reason, and there's no queue, then the email simply doesnt get sent (and an error is returned). If there is a queue, then sending will be re-tried later, and, hopefully, the email will eventually get sent.

Cons: If there's a queue, the part of the application that wanted to send the email doesnt know when (or even if) the email actually got sent. When you have a queue, you also have to have something that monitors the queue and raises an alert if there's a problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.