How to make the transactional email being sent asynchronously or synchronously?

  1. Open the backend «Stores» → «Configuration» page.
  • Go to the «Sales» → «Sales Emails» section.
  • Locate the «General Settings» → «Asynchronous sending» option and set it to the proper value («Yes» or «No»).

The default value is «No»:
https://github.com/magento/magento2/blob/135f967/app/code/Magento/Sales/etc/config.xml#L30-L30

How is it used:

https://github.com/magento/magento2/blob/135f967/app/code/Magento/Sales/Model/Order/Email/Sender/OrderSender.php#L82-L101


https://github.com/magento/magento2/blob/135f967/app/code/Magento/Sales/Model/Order/Email/Sender/InvoiceSender.php#L84-L103

See also:

A post was split to a new topic: «How " * - if $forceSyncMode parameter is set to TRUE" is set? Where?»

The asynchronous email sending solves the problems like this:

In my production instance calls like $mailer->send(); takes around 40 to 60 seconds.
php - Send asynchronous emails in Magento 1.6 - Stack Overflow

Please note that the asynchronous email sending does not work correctly for non-English stores:

https://github.com/magento/magento2/issues/6511

How are the send_email (setSendEmail, getSendEmail) / email_sent (setEmailSent, getEmailSent) flags used for an order?