Do you need to set up SendGrid for your site? The following step-by-step guide will help you get started.
SendGrid Account and Settings
Creating an Account
- Begin by creating your SendGrid account, click “Start for Free".
- You’ll create a username and password. Your Company Information can reflect the following:
Single Sender Authentication
- Navigate to “Settings” on the left menu, and click “Sender Authentication”. Click “Verify a Single Sender”.
- Fill out the contact information with your site’s “From Name”, “From Email Address”, and “Reply To” email address. These will likely be the email from your site. It is okay if the “Reply To” email matches the “From” email.
- The Company Address can match ASU’s address:
- Once you save, you should receive an email from SendGrid to verify your single sender and complete the process.
Creating an API Key
- Next, you’ll need to create an API Key. On the left panel, under “Settings” click on “API Keys”.
- Then, click “Create API Key”.
- When generating a new key, the first step will ask you which type of access you want it to have - full, restricted or billing. While full will work, we recommend using restricted with the following security settings set:
- You are also asked to give the key a “name”. We recommend using the Pantheon ID to name your API key because it will make it easier to know which API key goes to which account (there’s a 100 API key limit per Sendgrid account).
- The name mentioned above is NOT going to be the ID in your ID/password combo. The ID will ALWAYS be the string: apikey - for every key, in every Sendgrid account.
- Copy the actual API key string (69 characters long as of December 2022) and keep it for later in this process. This will be the PASSWORD when you are entering your new login credentials. You will not be able to see the API key again once your key is created.
Configure SendGrid on your Site
Module Installation and Configuration - SMTP
- You’ll need to install (via composer) and enable the following module:
- Once installed and enabled, go to the site’s SMTP settings form (in Webspark, it’s at /admin/config/system/smtp.) Make sure that the following settings are used:
- SMTP server: smtp.sendgrid.net
- Port: 587
- Use encrypted protocol: Use TLS
- SMTP Authentication:
- ID: apikey
- Pass: <the69CharacterString>
- E-mail from address: The email address that all emails will be from.
- Save the settings.
- Optional: Test it out on the same page (/admin/config/system/smtp):
- Turn on logging with “Log Everything” under Debugging and Logging.
- Enter a test email address in “E-mail address to send a test e-mail to”
- Click save. You’ll be given a long list of communication messages from the SMTP process that will tell you if the email submission was successful.
- If it says, “OK”, then wait for the email to arrive. It shouldn’t take more than 10-15 seconds.
- If the test works, turn off the logging (set to “No logging”) and resave the form again
Module Installation and Configuration - Mail System
- You’ll need to install (via composer) and enable the following module:
- Once installed and enabled, go to /admin/config/system/mailsystem
- Under "NEW SETTING", select the Webform module and enter "submission" in the Key field (that key corresponds with the webform_"submission" hook).
- Click Save Settings.
- The /admin/config/system/mailsystem page will reload with a new "Webform module (submission key) class" dropdown. Change that setting to "SmtpMailSystem" and save the settings again.
Additional Resources
Getting Started with the SendGrid API
SendGrid - SMTP configuration with API keys