Skip to content

Latest commit

 

History

History
131 lines (84 loc) · 4.41 KB

TROUBLESHOOTING.md

File metadata and controls

131 lines (84 loc) · 4.41 KB

If you have a non-library SendGrid issue, please contact our support team.

If you can't find a solution below, please open an issue.

Table of Contents

Migrating from v2 to v3

Please review our guide on how to migrate from v2 to v3.

Continue Using v2

Here is the last working version with v2 support.

Using rubygems:

Add this line to your application's Gemfile:

gem 'sendgrid-ruby',  '1.1.6'

And then execute:

bundle

Or install it yourself using:

gem install sendgrid-ruby -v 1.1.6

Download:

Click the "Clone or download" green button in GitHub and choose download.

Testing v3 /mail/send Calls Directly

Here are some cURL examples for common use cases.

Error Messages

To read the error message returned by SendGrid's API:

begin
    response = sg.client.mail._("send").post(request_body: mail.to_json)
rescue Exception => e
    puts e.message
end

Versions

We follow the MAJOR.MINOR.PATCH versioning scheme as described by SemVer.org. Therefore, we recommend that you always pin (or vendor) the particular version you are working with to your code and never auto-update to the latest version. Especially when there is a MAJOR point release, since that is guaranteed to be a breaking change. Changes are documented in the CHANGELOG and releases section.

Environment Variables and Your SendGrid API Key

All of our examples assume you are using environment variables to hold your SendGrid API key.

If you choose to add your SendGrid API key directly (not recommended):

sg = SendGrid::API.new(api_key: ENV['SENDGRID_API_KEY'])

becomes

sg = SendGrid::API.new(api_key: 'SENDGRID_API_KEY')

In the first case SENDGRID_API_KEY is in reference to the name of the environment variable, while the second case references the actual SendGrid API Key.

Using the Package Manager

We upload this library to RubyGems whenever we make a release. This allows you to use RubyGems for easy installation.

In most cases we recommend you download the latest version of the library, but if you need a different version, please use:

Add this line to your application's Gemfile:

gem 'sendgrid-ruby',  'X.X.X'

And then execute:

bundle

Or install it yourself using:

gem install sendgrid-ruby -v X.X.X

Rails Specifics

  • Namespace collision between Rails own Mail class and sendgrid class Mail. To avoid that issues please use SendGrid::Mail instead.

  • Possibility of a namespace collision between the sendgrid class Email and your own defined Email class. To avoid these issues, you can skip the include SendGrid line and use the SendGrid:: prefix for Email. Please see this SO answer for specifics.

Viewing the Request Body

When debugging or testing, it may be useful to examine the raw request header to compare against the documented format.

You can do this before response = sg.client.mail._('send').post(request_body: mail.to_json) like so:

puts mail