When the code is invoked via Drush Mailsystem crashes with next error.
Render context is empty, because render() was called outside of a renderRoot() or renderPlain() call.

The problem is in render() method which requires a context, which is not exist while running via Drush.

Related issue: https://www.drupal.org/node/2549835

Comments

danylevskyi created an issue. See original summary.

danylevskyi’s picture

I have a solution now. Working on a patch...

danylevskyi’s picture

StatusFileSize
new870 bytes
danylevskyi’s picture

Assigned: danylevskyi » Unassigned
Status: Active » Needs review
danylevskyi’s picture

danylevskyi’s picture

Issue summary: View changes
Jill L’s picture

I was having the same issue, trying to send email during a cron run.
This patch resolved that issue.

I think renderRoot instead of render is the right way to go, I'm going to mark this as reviewed.

Jill L’s picture

Status: Needs review » Reviewed & tested by the community

  • sgabe committed 4545c9d on 8.x-1.x authored by danylevskyi
    Issue #2801187 by danylevskyi: Mailsystem crashes when the code is...
sgabe’s picture

Status: Reviewed & tested by the community » Fixed

Committed, thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

audriusb’s picture

this is still a problem. when adding Mail handlers to webform and submitting webform via ajax - I get LogicException: A stray renderRoot() invocation is causing bubbling of attached assets to break. in Drupal\Core\Render\Renderer->renderRoot()

klemendev’s picture

This issue needs to be reopened as the problem is still present when the mail sending is triggered by AJAX. I use Comment Notify with AJAX Comment and when a comment is written, the exception is thrown and the comment is not sent.

EDIT1: Practically the same issue was fixed here: https://www.drupal.org/project/swiftmailer/issues/2825362. I think there is only a minor change inside MimeMail.php required to fix this.

EDIT2: I can confirm that changing renderRoot to renderPlain in MimeMail.php fixed the issue.

rick.kowal’s picture

"EDIT2" in #13 worked for me as well. I created a simple patch locally based on the patch in #3. Not sure if this is worth uploading.

klemendev’s picture

Someone reopen this issue, as it was not fixed yet. We need a patch and have it reviewed. Is there any active contributor who could do this?

klemendev’s picture

Just a small bump, is there any active contributor that could get this patch in a release?

jerdavis’s picture

StatusFileSize
new508 bytes

Uploading a patch with this change. Please test & confirm.

klemendev’s picture

I can confirm patch #17 works for me and fixes the issue I described in #13.

klemendev’s picture

Is there any maintainer that could get this into a release?

jerdavis’s picture

Status: Closed (fixed) » Reviewed & tested by the community

  • jerdavis committed d2d2a83 on 8.x-1.x
    Issue #2801187 by danylevskyi, jerdavis, Klemen Pevec, audriusb, rick....
jerdavis’s picture

Status: Reviewed & tested by the community » Fixed

Committed & pushed to 8.x-1.x

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.