Thursday, June 4, 2020

Send Email By SendGrid | Single Sender Verification method



Send Email By SendGrid | Single Sender Verification method
There are a variety of services in the market that allow you to send emails but most of them require a credit card to get started also some services like AWS SES are very hard to set up for those who don’t have knowledge of AWS. 
SendGrid is easy to set up, fast, reliable, and scalable service that helps you to get started for free without any card details and provide a basic plan to support your hobbies or startup ideas. At the time of writing this post, SendGrid provides 40,000 emails for 30 days and after that 100 emails per day for free. It is a well-known service used by UBER, Sportify, AirBand, etc. 

SendGrid is a cloud-based SMTP provider that allows you to send emails without worrying about technical details. 

The only downside is that you have to verify your account by their team which may take up to 24 hours but I think one can wait that long to use this awesome service for free. 

This article is divided into three parts:

Register to SendGrid

  • Navigate to SendGrid Pricing Page.
  • Select the Free Plan and click on the checkout button at the bottom right.
  • You will be navigated to their signup page. Fill the required details and click on Create Account.
  • After that, you have to fill two forms

     
    Sendgrid Registration Page | Form 1
     
    Sendgrid Registration Page | Form 2

  • Verify your mail and wait for the response 
It may take 24 hours or more to get verified. You will get an email that may look like this once your account get verified.
Sendgrid Account Activation Email




Setup SendGrid

There are two ways to send emails via SendGrid 
  1. Domain authentication 
  2. Single Sender Verification 
In Domain authentication method you can send emails by any email id of your domain example anything@yourdomain.com. We will see it later.

In Single Sender Verification you have to verify the emails from which you want to send emails. This is the easiest method and you don't need any domain to send emails. We will cover this method today.

Steps to send Email by Single Sender Verification

  • Once your account gets verified, log in to your SendGrid account.
  • From Left panel Settings -> Sender Authentication 

    Sender Verification
  • Click on Create New Sender button, a form will appear 
    Create New Sender Sendgrid
  • Once you fill the form and submit, you will get an email. Click on the link to verify the sender. 
    Sendgrid Sender Verified

Generating API Keys 

  • Navigate to Settings -> API Keys from the left panel.
    API Keys
  • Click on Create API Key select Full access from the menu  and generate keys.
    Generating API Keys
    You will be redirected to a page containing your API keys. Save your keys because you will not able to see those keys again in the portal.

    API Keys
Now you are ready to send Emails <(^-^)>


Sending Emails via Node.js

  • To send Emails I am using @sendgrid/mail package. It is easy to use and well-documented package to send mails by SendGrid.
  • You can get the code from here. Just replace the keys run npm i and npm start in the terminal.
    Code to send Email via NODE.js


You should receive a mail in your mailbox
Mail send via Sendgrid



Common Errors

  • If you see anything like this. That means your API keys are not valid or You are not using the email id you have verified
SendGrid Error while Sending Email

If you want to know how to explore the second method Domain Authentication you can refer to this article

Thank you for reading