Send Emails with a Custom Domain Using SendGrid and Rails


(Skcript Bot) #1

SendGrid is a cloud-based email delivery service that assists businesses with email delivery. That may sound like one of the most boring descriptions ever, considering the powerhouse of tools that SendGrid provides.

With SendGrid, you don’t just get to send emails - you get to monitor link clicks, unsubscribe rates, geographical tracking, and a lot more. In this tutorial, I’ll walk you through building your own email sending service on Rails with SendGrid.

The first thought that probably pops into your mind is Why SendGrid? Believe me, you’ll figure it out by the end of this tutorial.

Let’s first create a Rails project via command line. I’ll be using Rails 5 here.

rails new sendemail

(How creative of a name is sendemail though?)

We would like for users to sign up and then maintain a personal profile of all the emails they send. So, we’ll be adding the Devise gem here. I won’t be covering how to add Gems and customizing Devise in this tutorial, but here are a few sourcesthatcover it.

We’ll then create a scaffold called email. The model attributes will be the receiver field, subject field and body field—everything necessary to create an email! Oh, and we’ll also be adding a user_id mapping column, which will be used to query emails belonging to a user.

rails g scaffold email user_id:integer:index receiver:string subject:string body:text


This is a companion discussion topic for the original entry at https://www.skcript.com/svr/send-emails-with-a-custom-domain-using-sendgrid-and-rails/

(Karthik Kamalakannan) #2

This is a great post. Next up, can you write an article about sending emails via Sendgrid from a Google Cloud Platform Server?