"Superior quality instructions for the discerning online educator!" 🧐

Setting Up Email in Moodle with SendGrid

To reach students with Moodle announcements and forum subscriptions, you need to set up and configure a SMTP email service! This tutorial walks you through configuring email for your Moodle instance with the SendGrid SMTP service. We also explain some of the challenges with setting up email in general for Moodle.

SendGridxf logo SendGridxf logo

Email for Basic Moodle Features

"You'll need to set up email to use Moodle features like announcements and forum subscriptions."

Email notification is important for effective communication with your students on Moodle. For example, email notifications help keep your students informed about assignment deadlines, forum discussions, upcoming quizzes, course announcements, and user enrollment updates. Additionally, email lets students receive personalized communication from instructors and administrators, fostering community and facilitating collaboration.

Setting up email services is one of the final steps in the Moodle installation process before going live to your students. In our Moodle instance, we use SendGrid, a cloud-based email delivery platform.

SendGrid icon

SendGrid integrates with Moodle pretty easily.



"Why is email so complicated?"


Email is more complicated than you might think. First, there are several moving parts: Email servers consist of both mail transfer agents (MTAs) and mail delivery agents (MDAs) which have different jobs. There are also different web protocols in play. For example when a user sends an email, their email client communicates using protocols like SMTP (Simple Mail Transfer Protocol) to relay the message to the recipient's incoming mail server. The recipient's email client connects to the incoming mail server using a protocol like IMAP (Internet Message Access Protocol) or POP3 (Post Office Protocol). The incoming MTA works in conjunction with a mail delivery agent (MDA), responsible for placing the email into the recipient's mailbox. There's validation components, like the outgoing MTA validating the recipient's address before it routes the message across the internet.

Frustrated email man

Email is complicated :(


While, for Moodle you don't even need to configure your own mail transfer agent like Postfix (for example, instructions for installation with Ubuntu) because one called PHPMailer is already included, you will, however, need to configure a Mail Delivery Agent (MDA). However, setting up an MDA yourself through a service like Dovecot (a mail server which includes an MDA) can be a bit of a pain for the average LMS self-hoster if you want to ensure reliable service. The big kicker is spam. Because of spam, hardly anybody self-hosts their own email server. It's not that you can't set one up --rather the problem is that the email clients of your intended recipients probably won't trust you and your messages will end up in a spam folder.


"Why SendGrid?"


Using a cloud-based email delivery platform like SendGrid has a few big advantages:

  1. It's free if you're sending less than 100 emails/day.

  2. Big platforms like SendGrid are reliable: they are well-known, and email is all they do, which helps to minimize the risk of emails being marked as spam or bouncing.

  3. As it's cloud-based, it is easily scalable, potentially allowing you to send large volumes of emails if you're running multiple classes or a MOOC-style course with tons of students.

  4. It has good analytics tools, allowing you to track email engagement metrics such as open rates, click-through rates, and bounce rates, enabling you to see how your students are engaging with email communications.


"Why not use Gmail's SMPT service?"


When originally installing Moodle, my first inclination was to link one of my Gmail accounts. There are a bunch of instructions for this online (e.g., this MoodleDocs article), but this path isn't really viable:

  1. As of 2022, many of these Gmail approaches no longer work! You can check out Moodle.org forums like this one for more discussion. Apparantly, this was for security reasons. As many have noted, Google has been known to make pretty sweeping changes in some of their services, so it's not terribly surprising that this service has been discontinued.

  2. "To help keep your account secure, from May 30, 2022, ​​Google no longer supports the use of third-party apps or devices which ask you to sign in to your Google Account using only your username and password."

    - Google


  3. It's also worth noting that Moodle never really endorsed the Gmail approach for a production servers in the first place due to limitations on multiple "from" addresses and outgoing message limits.


Prerequisites



Instructions



1. Get Email Services from your Domain Provider


You can usually purchase email services attached to your domain through your domain provider. We usually use NameCheap. Accordingly, we will provide instructions for purchasing and configuring email through NameCheap, but if you use a different provider the process should be similar.

Log in to your NameCheap account and select the purchase option for "private email:"


Chess image

Purchasing private email on NameCheap


We purchased email for our domain with a basic package that comes with the option to create a single new mailbox:


Chess image

Creating a new mailbox


Once set up, you should be able to see your mailbox in your NameCheap profile:


Mailbox Setup

Mailbox Setup


You can log into the mailbox itself through in your domain options on NameCheap:


Log into Webmail

Logging into Webmail


2. Subscribe to SendGrid with the NameCheap domain email address


Just having a mailbox set up does mean that you are able to send emails through your LMS. You will need to link that address to an SMTP service that allows a relay to your LMS. You can sign up for the SendGrid email SMTP service on the SendGrid/Twilio website.


Setup Info

Registering your email address with Sendgrid


3. Verify your Moodle Email in SendGrid


Once you've signed up, you will need to verify your email address in SendGrid, so that they know that your email address is legitimate. You can either authenticate a single address or you can authenticate an entire domain using CNAME records.


Verified

Email Verification in Sendgrid


Setup Info

Single address authentication


Once your address is authenticated, you will see a checkmark icon under "verified:"


Verified

Email Verification in Sendgrid


4. Create API Key in Sendgrid


You'll need to create an API key in Sendgrid. This will allow for email to be sent through SendGrid from Moodle. This API key will be saved in Moodle (see the next step).


SMTP Relay option

Choose the SMTP relay option


Create API Key

Creating an API Key in Sendgrid


Checking Integration

Checking Integration


5. Configure Moodle SMTP Settings


In Moodle, you'll need to configure your outgoing mail settings to use the SendGrid API key. You can find this in the administration settings under "server" -> "outgoing mail configuration:"


SMTP Settings

Set the Moodle email SMTP configuration accordingly.


6. Set Your "noreply" Email


Make sure that the "noreply" address is set to an actual address or you will get an error:


No reply email

Make sure that the "noreply" address is set to an actual address!


7. Send a Test Email to Verify Proper Setup


You can send a test email through the Moodle admin settings to verify that everything is working properly:


Moodle Mail Test

Use the option to send a test email.



Conclusion


Setting up email for Moodle with SendGrid allows you, fellow instructors on your platform, and your students to communicate. So far, the SendGrid is a email delivery service has met all of our needs because it is relatively easy to set up and use.



References