Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I'm currently dealing with a client who is using a transactional mail service which has it's own MailSystem class. The client just sent out lots of emails which has exhausted their email quota. So for critical emails like "password resets" I would still like Drupal to handle the sending of those emails. Is it possible to detect which module/key the email is being sent from (e.g. user/password_reset) and choose an alternate MailSystem?
Comments
Comment #2
hargobindI found the answer to my own question.
In my case, I had created a simple sandbox module to load my generated MailSystem classes. It uses the HTMLMail module for formatting, and MailJet to send emails. During the send process, I modified the code to check the
module
value of the message and see if it belongs to theuser
module, then send it via Drupal's DefaultMailSystem. Other useful keys in$message
are 'module' and 'key', and 'id' which is a concatenation of "module_key".