Last active
July 6, 2016 15:20
-
-
Save sendgrid-gists/4be3a76b716e16c274c2ad0f6a99e9b4 to your computer and use it in GitHub Desktop.
v3 "Hello World" for email, using SendGrid with Ruby.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# using SendGrid's Ruby Library | |
# https://github.com/sendgrid/sendgrid-ruby | |
require 'sendgrid-ruby' | |
include SendGrid | |
from = Email.new(email: '[email protected]') | |
to = Email.new(email: '[email protected]') | |
subject = 'Sending with SendGrid is Fun' | |
content = Content.new(type: 'text/plain', value: 'and easy to do anywhere, even with Ruby') | |
mail = Mail.new(from, subject, to, content) | |
sg = SendGrid::API.new(api_key: ENV['SENDGRID_API_KEY']) | |
response = sg.client.mail._('send').post(request_body: mail.to_json) | |
puts response.status_code | |
puts response.body | |
puts response.headers |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment