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.
Comment | File | Size | Author |
---|---|---|---|
#3 | 2905185-sendgrid_integration-swiftmailer_compatibility-3.patch | 1.19 KB | juhog |
#2 | 2905185-sendgrid_integration-swiftmailer_compatibility-2.patch | 947 bytes | juhog |
Comments
Comment #2
juhog CreditAttribution: juhog at Druid for Lääkärikeskus Aava Oy commentedI 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.
Comment #3
juhog CreditAttribution: juhog at Druid for Lääkärikeskus Aava Oy commentedSmall update to the patch. Forgot
use Drupal\Component\Render\MarkupInterface;
from #2.Comment #8
Perignon CreditAttribution: Perignon commentedCommitted, reverted, committed :-)
Comment #9
parisekLooks like fixed issue
Comment #10
Perignon CreditAttribution: Perignon commentedOk, will update and make a new release.