0

I am attempting to add SendGrid to a Drupal 7 site. I have been following the offical sendgrid.com documentation for this, and following the instructions for using the smtp authentication support module. (https://sendgrid.com/docs/Integrate/Open_Source_Apps/drupal.html)

After installing and activating the smtp Authentication Support Module using drush (for which I used version 7.x-7.x-2.x-dev because of a bug with the default version), I was able to activate the module without error and follow the instructions in the documentation.

  • Going to configuration > System > SMTP Authentication Support
    • Turn the module on
    • Make sure Email delivery is turned on
    • Adding a provier witht eh name sendgrid
    • SMTP server: smtp.sendgrid.net
    • SMTP port 587
    • User encrypted Protocol: No
    • username and password for my sendgrid account
    • set email from address and email name
    • save configuration (which went through without error)

I then filled out a test email address and saved the configuration again.

I got a confirmation message that the settings were stored without error and that the test email had been sent.

I received the test email, but when I checked the headers on the email I received I can see that it has not arrived via SendGrid, but has come directly from my server. I can also see no activity on the SendGrid account at all. I have repeated the test sending system emails linked to user signup and I get the same result, I receive the email but it does not come via SendGrid.

I have also tried using port 465 and SSL as the encryption protocol, but while the the test email reported to have worked, I received no emails at all with these settings. Also as before no activity is logged in SendGrid.

Just to be thorough I tested my SendGrid account using telnet and was able to send an email using the same setting and account username and password used in drupal, including port number. The email was sent without issue, registered in SendGrid activity feed and the received email header references SendGrid.

I have gone as far as I can think of. Can anybody suggest where I might be going wrong?

3

We use SendGrid with SMTP Authentication Support and have not encountered any problems.

SendGrid may not allow unencrypted connections on port 587, depending on your package. That is the port for TLS/STARTTLS, so if you want to use port 587, you should select use TLS under Use encrypted protocol. This is how all of our sites that use SendGrid are set up.

One trick that can trip you up is the configuration of Mail System. If you use Mime Mail or another system that requires Mail System to be installed, you must configure Mail System to use SMTP explicitly, or it will fall back to Drupal's default mailer (PHP mail())

For a quick out of the box, you need to configure Mail System (/admin/config/system/mailsystem on Drupal 7) to use SmtpMailSystem for your module class (for example as the Mime Mail module class, or as the Site-wide default MailSystemInterface class).

For an alternative integration option, there is a SendGrid Integration module which uses the API rather than plain SMTP.

  • the Mail System config sounds like my issue. I did not setup the site myself but looking at the Drupal install, its seems to be a stock install, probably automated. I will look into this and confirm ASAP. – Finglish Sep 29 '16 at 7:44
  • 1
    Thanks! You were right on the money, it was falling back to mail(). – Finglish Sep 30 '16 at 6:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.