Git Product home page Git Product logo

sendgrid-mailer's Introduction

README

Ruby on Rails Email API using SendGrid

Requirements

  • Ruby version: 2.5.5

rbenv or similar ruby environment management tool

rbenv install 2.5.5

  • Rails version: 5.1.7

gem install rails -v 5.1.7

Setup

gem install bundler -v 2.0.2

# cd to root directory
cd sendgrid-mailer/

bundle install

HTTP Request

  • /email POST

Steps:

1. JSON input:

{
    "to": "[email protected]",
    "to_name": "Recipient",
    "from": "[email protected]",
    "from_name": "Sender",
    "subject": "BrightWheel Email API test",
    "body": "<h1>Dear World</h><br><p>Hello</p>"
}
  1. API Key. See attachment

    Download attachment and move file to root directory of project

    Source the environment file for the API key

    source ./sendgrid.env

    Start the rails server

    bundle exec rails s

  2. Send a POST request using a HTTP client with the JSON body

    http://localhost:3000/email

    Header: Content-Type => 'application/json'

NOTES

  • Made use of the rest-client gem to execute the POST request. The Reason was I was familiar with the gem and it is well-documented and easy to use.
  • With more time, I would have added simple unit testing to test the Helper class and the Controller
  • HTML to plain text is achieved using Nokogiri::HTML class. In rails, I have used it in the past. With more time I could research a more elegant solution.
  • Validations currently checks for presence of the parameter and a nil check. This could be expanded to check format of the email
  • API supports a single email address, this could further expanded to support multiple email addresses. Requires building the list of email addresses.

sendgrid-mailer's People

Contributors

dependabot[bot] avatar vshl avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.