This library allows you to quickly and easily use the SendGrid Web API via Ruby.
BREAKING CHANGE as of 2016.06.14
2.0.0 is a breaking change for the entire library.
Version 2.0.0 brings you full support for all Web API v3 endpoints. We have the following resources to get you started quickly:
Thank you for your continued support!
All updates to this library is documented in our CHANGELOG.
Setup Environment Variables
First, get your free SendGrid account here.
Next, update your environment with your SENDGRID_API_KEY.
echo "export SENDGRID_API_KEY='YOUR_API_KEY'" > sendgrid.env echo "sendgrid.env" >> .gitignore source ./sendgrid.env
Add this line to your application's Gemfile:
And then execute:
Or install it yourself using:
gem install sendgrid-ruby
require 'sendgrid-ruby' include SendGrid from = Email.new(email: '[email protected]') subject = 'Hello World from the SendGrid Ruby Library' to = Email.new(email: '[email protected]') content = Content.new(type: 'text/plain', value: 'some text here') 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
General v3 Web API Usage
require 'sendgrid-ruby' sg = SendGrid::API.new(api_key: ENV['SENDGRID_API_KEY']) response = sg.client.api_keys.get() puts response.status_code puts response.body puts response.headers
If you are interested in the future direction of this project, please take a look at our milestones. We would love to hear your feedback.
How to Contribute
We encourage contribution to our libraries, please see our CONTRIBUTING guide for details.
sendgrid-ruby is guided and supported by the SendGrid Developer Experience Team.
sendgrid-ruby is maintained and funded by SendGrid, Inc. The names and logos for sendgrid-ruby are trademarks of SendGrid, Inc.