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?
Drupal Answers is a question and answer site for Drupal developers and administrators. It only takes a minute to sign up.Sign up to join this community
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.
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.
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.
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.