Our system is using Swift Mailer for formatting the emails and Sendgrid Integration for sending them.

When an email arrives to the email client from Sendgrid, the HTML part of the message looks totally incorrect. Swift Mailer template markup is totally gone and the HTML part practically looks like a plain-text email.

The problem seems to be in SendGridMail class mail() method line 256:

$sendgrid_message->setHtml($message['body']);

Swift Mailer format() returns the message body as a Markup object and setHtml method apparently can't handle that. If I transform the Markup object into a string, the emails are working correctly.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

juhog created an issue. See original summary.

juhog’s picture

I changed the mail() method handling of text/html emails. Message body is checked if it's a Markup object, and it's tranformed into a string before adding it as HTML.

This has fixed the problem in our setup where Swift Mailer formats the emails.

juhog’s picture

Small update to the patch. Forgot use Drupal\Component\Render\MarkupInterface; from #2.

  • Perignon committed 6ba4527 on 8.x-1.x authored by juhog
    Issue #2905185 by juhog: Compatibility issue with Swift Mailer
    

  • Perignon committed 76fc87d on 8.x-1.x
    Revert "Issue #2905185 by juhog: Compatibility issue with Swift Mailer...

  • Perignon committed 78726ee on 8.x-1.x authored by juhog
    Issue #2905185 by juhog, Perignon: Check to see if the message is a...

Perignon credited Perignon.

Perignon’s picture

Committed, reverted, committed :-)

parisek’s picture

Status: Needs review » Fixed

Looks like fixed issue

Perignon’s picture

Ok, will update and make a new release.

Status: Fixed » Closed (fixed)

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