- 🇬🇧United Kingdom steven jones
I think that the solution here is to get the async sending working in Drupal Symfony Mailer, which seems to want to have it's own API and do things in it's own way, outside of lots of the existing Drupal ecosystem for mail sending. so marking this as a 'won't fix'.
- 🇳🇿New Zealand heathergaye
Hey, I needed this working in a hurry, so I've written a quick & dirty patch for the queue_mail version 8.x-1.x.
Queue worker just re-sends the email using the standard mail manager, and bypasses the queue_mail_mail_alter intercept by setting a flag in the message params.
Purely for reference if anyone else needs this in a hurry; I expect the module authors had reasons not to do this.
No guarantees, but it works for me. - Status changed to Active
about 1 year ago 11:38am 13 October 2023 - 🇨🇿Czech Republic parisek
I found pretty good example how it could be implemented in this module (use EmailAdjuster) https://www.drupal.org/project/maillog/issues/3259616 ✨ Support Symfony Mailer RTBC
I think it's unnecessary to create separate module for this feature.
- 🇳🇴Norway hansfn
I'm the maintainer of the Views Send module. (No, don't every copy code from it - it's vey messy.)
My understanding is that MailManagerReplacement (and LegacyMailerHelper) should have made our old code work. However, there seems to be an issue that could explain the missing
$mail['queued']
: 🐛 Wrong return value for MailManagerReplacement::mail() Active . In addition, if you are queue by setting send to false, you are probably also affected by 🐛 MailManagerReplacement::mail() doesn't always compose Active .If these two are fixes, I think VS and QM should work with Symfony Mailer without any changes.
- 🇦🇺Australia mustafa_abdalle
I'm using Symfony Mailer + Queue Mail and when I send an email from my custom code (custom form) using:
$mail= $mailManager->mail($module, $key, $to, $langcode, $params, $reply, $send);
The queue mail cannot send the email and throws the error:
sh: 1: /usr/sbin/sendmail: not found [error] Error sending email (from <email address> to <email address> with <email address>).
I did not encounter this issue when I'm using the old Mail System + SwiftMailer + Queue Mail modules.
Also, when I try to send a reset password and a test email while Symfony Mailer + Queue Mail modules are enabled, the emails are sent just fine.
My Implementation:
- Using SMTP Mail policy for Symfony Mailer
- Custom Module that uses Drupal MailManager to send an email.
- I have implementedhook_mail
in my custom module.function MODULE_mail($key, &$message, $params) { switch ($key) { case 'custom_key': $message['subject'] = $params['subject']; $message['body'][] = $params['body']; $message['from'] = \Drupal::config('system.site')->get('mail'); break; default: $message['subject'] = 'Default'; $message['body'][] = 'Default Key'; $message['from'] = \Drupal::config('system.site')->get('mail'); } }
is this related to Queue Mail not compatible yet with Symfony Mailer?
- 🇳🇴Norway hansfn
is this related to Queue Mail not compatible yet with Symfony Mailer?
No, very unlikely since 1) you get the error about /usr/sbin/sendmail not found and 2) the reset password mail is sent. I guess your custom code is using another transport plugin (sendmail) than the reset password test. Create another issue if you need help.
- 🇮🇹Italy plach Venezia
FYI queue/async support for Symfony Mailer is being added at ✨ Add Symfony Messenger support for async messsages (emails as queues) Active .
- 🇮🇳India omsingh89
We are getting below error when an email is queued.
Warning: Undefined array key "from" in Drupal\queue_mail\Plugin\QueueWorker\SendMailQueueWorker->processItem() (line 169 of \web\modules\contrib\queue_mail\src\Plugin\QueueWorker\SendMailQueueWorker.php)Steps to replicate:
1. Write an custom hook_mail logic. for example:
function my_module_mail($key, &$message, $params) {
$message['headers']['Content-Type'] = 'text/html; charset=UTF-8; format=flowed; delsp=yes';
switch ($key) {
case 'custom_notification':
$message['subject'] = t($params['subject']);
$message['body'] = [t($params['body'])];
$message['from'] = \Drupal::config('system.site')->get('mail');
break;
}
}
2. Trigger email as per logic.
3. Email will get queued and then run Cron to receive email.FYI, the error is around code written in patch #8
+ $message = $this->mailManager->mail(
+ $message['module'],
+ $message['key'],
+ $message['to'],
+ $message['langcode'],
+ $message['params'],
+ $message['from']
+ );