First, thanks for your work on this module!
I have a site that uses Rules extensively to send emails. Unfortunately, it seems that SendGrid Integration strips out <a>, <strong>, <em>, etc tags...
I have tried Mime Mail (and its Send a HTML email rule) however it seems that it's not compatible with this module (?).
I've also tested Swift Mailer to send via SendGrid SMTP (instead of this module). It does send in HTML format from Rules' Send mail action, but it lacks support for SendGrid categories that I'll need for reporting.
How would I go about sending HTML emails from Rules with SendGrid Integration?
Comment | File | Size | Author |
---|---|---|---|
#4 | 5_Mime_Mail___config.png | 84.86 KB | ajmartin |
#4 | 5_Mail_System___config.png | 109.4 KB | ajmartin |
#4 | 4_mimemail_maillog_send_html_mail.txt | 1.4 KB | ajmartin |
#4 | 3_htmlmail_maillog.txt | 704 bytes | ajmartin |
#4 | 2_Rule_send_html_mail.txt | 774 bytes | ajmartin |
Comments
Comment #2
Perignon CreditAttribution: Perignon as a volunteer commentedIf the message has the x-html header set in the message array it will be sent as HTML formatted.
I send HTML emails with rules daily but I use HTMLmail module which sets the header.
Also check your mailsystem settings to make sure mail is being processed through your installed modules correctly.
Comment #3
ajmartin CreditAttribution: ajmartin commentedThanks for the super quick reply. I'll give HTMLmail a try.
Comment #4
ajmartin CreditAttribution: ajmartin commentedSo, after testing with HTMLmail I am indeed able to send HTML emails via Rules. However... it would be good to include a plain text version, as per SendGrid's recommendations. HTMLmail doesn't seem to do this without Mail Mime, which requires Pear (not possible in my production env) or Include - which has been out of order for two years: www.drupal.org/node/2294753.
Mime Mail does support sending HTML & plain text versions, however it doesn't appear to work well with SendGrid Integration. Perhaps because of the Header
Content-Type: multipart/mixed
?In case it helps, I've attached:
So, am I missing something? Or is better integration with Mime Mail something that I should add as a feature request?
Comment #5
Perignon CreditAttribution: Perignon as a volunteer commentedI will look into what headers Mime mail sets. I have not, to date, used Mime Mail so I will have to do some testing.
As far as the text only emails. I send about 800,000 to 1 million emails a month for marketing and do not include a text version of the HTML message, has not been an issue in my experience of doing this for six years.
I could add code to strip the HTML tags of the message and create a text only version.
Comment #6
Perignon CreditAttribution: Perignon as a volunteer commentedA little follow-up. So if text/html is not set as the Content-Type in the headers any HTML tags get stripped from the message to sanitize the message.
I have updated the README with this information and I will investigate the industry norm with the headers and the content types.
Comment #8
ajmartin CreditAttribution: ajmartin commentedThanks for looking into it, Perignon. Being able to use Mime Mail's send HTML email rule with SendGrid would be really handy!
I believe that this could be accomplished by moving setText() outside the else block on line 171 of sendgrid.mail.inc:
I've tested the above change briefly; emails sent as HTML are received with both plain text and html versions.
Comment #10
Perignon CreditAttribution: Perignon as a volunteer commentedI committed a change that should always send a text version of the email as suggested in #8.
Comment #11
Perignon CreditAttribution: Perignon as a volunteer commentedAdding a new related issue.
Comment #12
Perignon CreditAttribution: Perignon as a volunteer commented@ajmartin I have been doing a lot of testing with MIMEmail module and have come to the conclusion it is not compatible with Sendgrid unless you are going to use the SMTP module and not the Sendgrid Integration module. I am updating the documentation for the module to reflect this.
While I was able to get the messages to send in HTML with MIMEmail, MIMEmail will embed the CSS into the message through it's own templating system which I cannot get to work correctly. It puts the body of the email into the wrong portion of the template. As much as I tried changing configurations with Mailsystem I cannot get this to stop.
I am going to leave the multipart/mixed code in the SendGrid Integration module so that a message sent as that will function to some extent.
I do not personally use MIMEmail because of the lack of template control, so if someone else wants to do more testing with MIMEmail I will accept any contributions!
Comment #13
MrPeanut CreditAttribution: MrPeanut commentedAre you saying it is possible to send HTML emails via Rules using the SMTP Authentication Support module alone?
I also had trouble with this. My goal is to send HTML emails from Rules (via Queue Mail) through SendGrid. I don't really care which modules I use. What set of modules accomplishes this?
Comment #14
ajmartin CreditAttribution: ajmartin commented@Perignon Sounds like a sensible decision. I had poked around a little initially to see if there was a simple solution, but as a novice coder it got beyond me.
Defaulting to sending plain/text in addition to HTML accomplishes all that I need, so thank you for work on this!
Comment #15
ajmartin CreditAttribution: ajmartin commented@MrPeanut
Yes - see sendgrid.com/docs/Integrate/Open_Source_Apps/drupal.html
But for me, using SendGrid Integration is better. By default, Rules will send emails as plain text. If you use HTMLmail and configure Mail System correctly Rules will send HTML emails.
I didn't find Mail System's config particularly intuitive to begin with, so if you need a tip check out the 5_Mail_System___config.png attachment, and swap HTMLMailSystem for MimeMailSystem.
Comment #16
Perignon CreditAttribution: Perignon as a volunteer commented@MrPeanut Just use HTMLmail and everything will work like a charm. MIMEmail added a lot of complexity that you do not need. SendGrid, when used as we do in this module, is used as a web service to send email. It is not SMTP so the mail is not sent in an RFC format.
I submitted, and was accepted, a pull request to update sendgrid.com/docs/Integrate/Open_Source_Apps/drupal.html to include the SendGrid Integration module. On their next update of the docs you will see it. https://github.com/sendgrid/docs/pull/1734
Comment #17
Perignon CreditAttribution: Perignon as a volunteer commentedMarking fixed.
Comment #19
ashroof CreditAttribution: ashroof commentedAny solutions yet
Comment #20
apoc1 CreditAttribution: apoc1 commented#19 is not working. Gives following error:
It sends the mail with the HTML included as attachment. Serious questions about security on this solution too.