Closed (fixed)
Project:
SendGrid Integration
Version:
7.x-1.x-dev
Component:
Miscellaneous
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
12 Oct 2016 at 22:26 UTC
Updated:
14 Apr 2020 at 03:05 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
perignon commentedYou have to create a new class that uses HTMLmail for processing and SendGrid for sending.
Like this:

Comment #3
cycas commentedI tried that, but the new class gave me this error when I tried to use it :
GuzzleHttp\Exception\ClientException: Client error: `POST https://api.sendgrid.com/api/mail.send.json` resulted in a `400 Bad Request` response: {"errors":["Missing email body"],"message":"error"} in GuzzleHttp\Exception\RequestException::create() (line 107 of /home/tavata/public_html/sites/all/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php).
I get that both from Views Send and from the HTML Mail Test mail functionality when I use the HTMLMailSystem__SendGridMailSystem class.
Did you have to make a change to the HTMLmail template to get Sendgrid to accept the format or something?
Comment #4
perignon commentedCan you send an email using the testing function in the Sendgrid module?
Comment #5
cycas commentedI can send an email via Sendgrid's testing function, but not in HTML format. It arrives displaying unformatted HTML if I try to send a Full HTML email.
I tried experimenting with the filters in HTMLmail and if everything is set to filtered HTML, then I can send email using Views Send or HTMLmail test, but the emails don't come out formatted.
I feel like I'm missing something obvious here. :-(
Comment #6
perignon commentedHave you configured/made templates for HTMLmail?
Comment #7
cycas commentedYes, I made a copy of the generic template. I assume it must be working if I can send via HTMLmail and the local server and have HTML email arrive, but not send HTML via Sendgrid?
Comment #8
cycas commented... OK, I finally got this working by reinstalling the Mime Mail module and setting up a MimeMailSystem_SendgridSystem class to use with Views Send module at admin/config/system/mailsystem, instead of HTMLmail .
I know Mimemail module isn't supposed to work with Sendgrid module, but what can I say, apparently it does for me, and HTMLmail doesn't.
Views Send does say that it won't send HTML unless Mimemail is installed, so that may be where some of my issues were coming from.
Comment #9
perignon commentedGlad that you got something working. I use HTMLmail and the Sendgrid module a lot so the problems may stem from Views Send. The Views Send module seems to be peculiar in how it works. Other have posted problems with that module.
Comment #11
matt bI couldn't get either to work. However putting
$message['headers']['content-type']= 'text/html';in my _mail_alter() in a custom module did the trick....
Comment #12
ryank76 commented#8 worked for me too, thank you!
Comment #13
chicagomom commentedWhen I tried to create a new class as #2, I get: Fatal error: Class 'HTMLMailSystem__SendGridMailSystem' not found in /.../sites/all/modules/mailsystem/mailsystem.module on line 293.
Comment #14
sam452 commentedComing in late here. When you created MimeMailSystem_SendgridSystem class did you just duplicate a rename the MimeMail class in mimemail/src/Plugin/Mail/ ? What is in this class and where should it be placed to be picked up by the mail system? In its own module?
Comment #15
perignon commentedThis is performed in the UI, not in the source code (Relative URL: admin/config/system/mailsystem)
Comment #16
wOOge commentedHere's what I had to do:
HTMLMailSystem__SendGridMailSystem.mail.incwas saved in/srv/private_files/. But Drupal couldn't find it. So I had to move it to a new location and change the perms on it./sites/default/files/mailsystem. So the path should be:/sites/default/files/mailsystem.mv /srv/private_files/HTMLMailSystem__SendGridMailSystem.mail.inc /srv/www/website.com/sites/default/files/mailsystemHTMLMailSystem__SendGridMailSystem.mail.incfile to something like755registrytable.HTMLMailSystem__SendGridMailSystemfilenamecolumn, to match the new location of your New Class file, BUT MAKE IT RELATIVE to your web root. For example:sites/default/files/mailsystem/HTMLMailSystem__SendGridMailSystem.mail.incdrush cc alladmin/config/system/mailsystemand set your settings to this:HTMLMailSystem__SendGridMailSystemSendGridMailSystemHTMLMailSystemThat's what I had to do on Drupal 7.63 with the latest version of all modules involved at this time.
I hope that helps someone.
Comment #17
daggar commentedThanks to wOOge for #16 . That works for me, as of Drupal 7.67.
I modified his routine slightly; putting the template in the publically-accessible
filesdirectory made me nervous.Instead, I put mine in the less-vulnerable theme directory. So, instead of
sites/default/files/mailsystem/HTMLMailSystem__SendGridMailSystem.mail.incI placed mine in
sites/all/themes/[site_theme_dir]/HTMLMailSystem__SendGridMailSystem.mail.inc...where
[site_theme_dir]is changed to the directory of your specific install's theme.Then I updated the database entry accordingly to that changed path, and it works.
Comment #18
daggar commentedComment #19
finaukaufusiThe important part of this, is the "Database update" to the registry table. You don't need to un-install and re-install the modules. Just make sure the value inside the registry table is correct. Eg, the path is correct.
Comment #20
npoku commentedConfirm firming #11 worked for me.
Running: Drupal 7.69
Sendgrid Integration: 7.x-1.4+6-dev
HTML Mail: 7.x-2.71
Mime (just in case you need it, why not) 7.x-1.1)
Host: Pantheon
Just for my sanity & future reference....
In my case, I kept on getting a MIME encoded message on top of my actual correctly formatted HTML message body. This was being caused by routing my HTML formatted message via Sendgrid. Solution is to turn off Step 3 "Provide simple plain/text alternative of the HTML mail." on the HTML module settings page (/admin/config/system/htmlmail). Hope this helps someone in future.