Scott's Thoughts Pamphlet!

🤫This is a private post👀

Sending Emails With Twilio SendGrid

Now I have a super sweet email pipeline for sending weekly emails thanks to Sam Larsen-Disney I’m going to document what I’ve learnt and what Sam taught me. (same thing, I guess) 😊

First up, I’d like to thank Sam for his patience walking me through this a couple of times over now.

If you are looking to do something similar then the hope is that this can give you an idea of what you need to do.


There’s no real prerequisites here I’d say, having an email from your custom domain is a nice touch but as far as I know not essential.

If you want to set up a custom email address to send from, I have done this in the past with Zoho and you can check Setting up a Custom Email with Zoho for details on that and also Setting up ProtonMail with Vercel they’re both for Vercel via the Vercel CLI.

I’ll need a from on my site to collect the information with, I use Kews Forms which isn’t completely redundant a this point as it has great validation that I can use.

Also it was what I had in place already, if you’re interested in Kews Forms take a look at the video here:

There are also other videos from friends of mine detailing the same process:

Add contacts to SendGrid

This is the code Sam kindly furnished me with, this can be gleaned from SendGrid as well.

2 * This is what is used to send the contact to SendGrid
3 * the `list_ids` is from my contacts list in SendGrid
4 * that is the id of my Newsletter list
5 */
7export default async function happyForm(email, name, list) {
8 await fetch('', {
9 method: 'PUT',
10 headers: {
11 'Content-Type': 'application/json',
12 Authorization: `Bearer ${process.env.GATSBY_SENDGRID_API_KEY}`,
13 },
14 body: JSON.stringify({
15 list_ids: [list],
16 contacts: [
17 {
18 email,
19 first_name: name,
20 },
21 ],
22 }),
23 })

To do that, if you create a new list in your contacts then

sendgrid empty contact list

Back to Top

Scott Spence

Built with Gatsby · Hosted on Vercel · 2021