- Issue created by @chrotto
- 🇳🇴Norway hansfn
Will look at this, this week. I think the problem is present for Drupal 10 too, but if you have the possibility to confirm that it would be great.
- Assigned to hansfn
- 🇸🇪Sweden chrotto
Yes, it is the same problem with Drupal 10.1.5 and Views Send 2.0.0-rc1
Tested with Default PHP mailer in Mail system settings.
The process worked fine all the way but when the text was converted to mail the formatted text became plain text.
I also tested with Mime Mail installed but this did not work for me. Think it is better if Mime Mail is not needed.
I hope you can get this to work because I think it is a very useful module. - 🇳🇴Norway hansfn
Just to make it clear - to send formatted mail in Drupal in general, you need some kind of MIME supporting Mail module.
You have tested with Mime Mail → for both D9 and D10 and you got the errors you posted?
- 🇸🇪Sweden chrotto
I now tested with Mime Mail and with core 10.1.5 and got a serious error:
Symfony\Component\Mime\Exception\RfcComplianceException: Email "" does not comply with addr-spec of RFC 2822. in Symfony\Component\Mime\Address->__construct() (line 54 of /var/www/dev.godnattsagan.se/vendor/symfony/mime/Address.php).Doing the same with the Default PHP mailer I did not get any errors but an extra asterisk on both ends of the text:
*Testing Views Send with Default PHP mailer and this text in Bold*
So for me, it seems to be less work without Mime Mail.
/Chrotto
- 🇳🇴Norway hansfn
Yes, an empty string doesn't comply with the RFC 2822 ;-)
I need to see the definition of the fields you use for mail and subject / title for the mail. Either explain, take some screen dumps or export config for the view. Maybe the fields are displaying HTML instead of plain text causing problem - I don't know.
I have tested with D9 and D10 - without and with MimeMail, as user 1 and as content author (with "View user email addresses" permission). The only problem I have is that user tokens aren't replaced - everything else just works.
- 🇳🇴Norway hansfn
Thank you for the view config. They look fine. I prefer setting the mail field to plain text, but that isn't the reason for your problems.
When sending mail, are you user 1? Or a user with permission "View user email addresses" permission? When displaying the view, I assume the mail field does display with a value in each row. Could you limit the view to just one row. Still same error? What is the value of the mail field?
- 🇸🇪Sweden chrotto
When testing before I was user 1. I tested now with user "View user email addresses" permission; it was the same error.
During tests, I always only send to one user. - 🇳🇴Norway hansfn
I'm sorry, but I think the focus on the mail field was a distraction - the error from your log file is
[..] __construct('subject', NULL)
It's always the mail field that causes the problem, but here it seems to be the subject. So I assume the error message is correct, what do you enter for the Subject when composing the mail? A token? If so, what?
- 🇳🇴Norway hansfn
And, I noticed in the error log, that the line numbers doesn't match mine. Could you post the content of the function views_send_deliver (in the file views_send.module)? (Wrap it in code tags.)
- 🇸🇪Sweden chrotto
When tested with the Subject: "Testing Views Send" I got the error.
I had a hired developer earlier who looked at this and suggested a patch or uninstalling Symphony Mail. I uninstalled the module and then it was working, but without formatting the text.
I attached the patch he suggested but I did not useHere is the code: from Views Send
code>function views_send_deliver($message) {
if (is_array($message)) {
$message = (object) $message;
}$key = 'direct';
$headers = unserialize($message->headers);$mail = array(
'to' => $message->to_mail,
'from' => $message->from_mail,
'subject' => $message->subject,
'body' => $message->body,
'headers' => $headers,
);// Adding attachments explicitly because Swift Mailer and Mandrill doesn't
// handle attachments in the format function. Only works for batch delivery of mail.
if (!empty($message->params) && (\Drupal::moduleHandler()->moduleExists('swiftmailer') || \Drupal::moduleHandler()->moduleExists('mandrill'))) {
$mail['params'] = $message->params;
}$system = $mail_backend = \Drupal::service('plugin.manager.mail')->getInstance(array('module' => 'views_send', 'key' => $key));
return $system->mail($mail);
} - 🇳🇴Norway hansfn
OK, things are getting clearer.
Using Drupal Symfony Mailer doesn't work - as expected. There is no code to handle it, and it uses a new interface. I will fix that.
However, from your initial post it's hard to tell if you got formatted mail to work with Mime Mail or nor. I suggest creating a new issue if you have a problem with Mime Mail. It should work - just follow step 6 in the Setup instructions → .
- 🇸🇪Sweden chrotto
As I said in my initial post I have tested Views Send with both Mime mail and Default PHP mail mailer.
I also used settings as in 6 so I do not think it shall be needed with a new issue. - 🇳🇴Norway hansfn
The title of this issue is "Impossible to send formated emails". If you have used Mime mail successfully, you should have sent formatted e-mails. So what is it?
Yes, I will fix the issue Drupal Symphony Mailer.
- 🇸🇪Sweden chrotto
It is impossible to send correct formatted mail with Mime Mail in both D9 and D10.
In D10 with Mime Mail mailler View Send hang.
Log Message:
Symfony\Component\Mime\Exception\RfcComplianceException: Email "" does not comply with addr-spec of RFC 2822. in Symfony\Component\Mime\Address->__construct() (line 54 of /var/www/dev.godnattsagan.se/vendor/symfony/mime/Address.php).In D9 with Mime Mail mailer I get this message (in swedish, sorry)
Ett AJAX HTTP-fel inträffade
Resultatkod för HTTP: 200
Felsökningsinformation följer.
Sökväg: /batch?id=1108&op=do_nojs&op=do
Statustext: parsererror
Svarstext:And the following Log message:
TypeError: Symfony\Component\Mime\Header\UnstructuredHeader::__construct(): Argument #2 ($value) must be of type string, null given, called in /var/www/malmonshamnochbat.se/web/core/lib/Drupal/Core/Mail/Plugin/Mail/PhpMail.php on line 98 in Symfony\Component\Mime\Header\UnstructuredHeader->__construct() (line 23 of /var/www/malmonshamnochbat.se/vendor/symfony/mime/Header/UnstructuredHeader.php)#0 /var/www/malmonshamnochbat.se/web/core/lib/Drupal/Core/Mail/Plugin/Mail/PhpMail.php(98): Symfony\Component\Mime\Header\UnstructuredHeader->__construct('subject', NULL)
#1 /var/www/malmonshamnochbat.se/web/modules/contrib/views_send/views_send.module(874): Drupal\Core\Mail\Plugin\Mail\PhpMail->mail(Array)
#2 /var/www/malmonshamnochbat.se/web/modules/contrib/views_send/views_send.module(882): views_send_deliver(Object(stdClass))
#3 /var/www/malmonshamnochbat.se/web/core/includes/batch.inc(295): views_send_batch_deliver(Array, false, Array, Array)
#4 /var/www/malmonshamnochbat.se/web/core/includes/batch.inc(137): _batch_process()
#5 /var/www/malmonshamnochbat.se/web/core/includes/batch.inc(93): _batch_do()
#6 /var/www/malmonshamnochbat.se/web/core/modules/system/src/Controller/BatchController.php(55): _batch_page(Object(Symfony\Component\HttpFoundation\Request))
#7 [internal function]: Drupal\system\Controller\BatchController->batchPage(Object(Symfony\Component\HttpFoundation\Request))
#8 /var/www/malmonshamnochbat.se/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array)
#9 /var/www/malmonshamnochbat.se/web/core/lib/Drupal/Core/Render/Renderer.php(580): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#10 /var/www/malmonshamnochbat.se/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
#11 /var/www/malmonshamnochbat.se/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array)
#12 /var/www/malmonshamnochbat.se/vendor/symfony/http-kernel/HttpKernel.php(169): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#13 /var/www/malmonshamnochbat.se/vendor/symfony/http-kernel/HttpKernel.php(81): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
#14 /var/www/malmonshamnochbat.se/web/core/lib/Drupal/Core/StackMiddleware/Session.php(58): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#15 /var/www/malmonshamnochbat.se/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#16 /var/www/malmonshamnochbat.se/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#17 /var/www/malmonshamnochbat.se/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#18 /var/www/malmonshamnochbat.se/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#19 /var/www/malmonshamnochbat.se/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#20 /var/www/malmonshamnochbat.se/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#21 /var/www/malmonshamnochbat.se/web/core/lib/Drupal/Core/DrupalKernel.php(718): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#22 /var/www/malmonshamnochbat.se/web/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
#23 {main}Using Default PHP mailer in D10 there is no errors but the Bold text was marked with * before and after.
*Testing Views Send with Default PHP mailer and this text in Bold*Using D9 and Default PHP mailer I got the same error as with Mime Mail
- Status changed to Closed: won't fix
over 1 year ago 2:08pm 17 October 2023 - 🇳🇴Norway hansfn
So then I was correct: This is infact two problems - 1) missing support for Drupal Symphony Mailer (which is an expected problem) and 2) problems with using Mime Mail for formatted and plain text e-mail (which I can't reproduce).
It's a mess to discuss and fix two problems at the same time, so I'll close this issue now. I'll recreate an issue for Drupal Symphony Mailer so it's documented that there is a problem.
The problem with Mime Mail i think is related to the fact that you used Drupal Symphony Mailer. I experienced the same myself. Even after uninstalling it, mail sending (with Views Send) didn't work. I tried a lot of things, but I think what fixed it was to deselect "Send the message directly using the Batch API." once and sending - and turning it back again. Maybe a cache issue. Haven't had time to investigate.