3
votes

I am trying to send mail using Rails 5.2 and Sendgrid. I have read tutorials how to set it up. However, all I am finding are ways to setup the SMTP method of sending, which is slower than the API method. Example: https://medium.com/le-wagon/how-to-send-email-with-action-mailer-and-sendgrid-in-rails-5-32ed0c9167fd

Using the standard sendgrid gem: https://github.com/sendgrid/sendgrid-ruby

Is there anyway to send email using action mailer and the API method? I don't want to just authenticate with the api key, I want to send mail using the api, not SMTP.

1

1 Answers

2
votes

Not using the standard sendgrid gem, but did see this gem:

https://github.com/eddiezane/sendgrid-actionmailer

that allows for action mailer to use api method by adding the following to config/environments/production.rb:

config.action_mailer.delivery_method = :sendgrid_actionmailer
config.action_mailer.sendgrid_actionmailer_settings = {
  api_key: ENV['SENDGRID_API_KEY'],
  raise_delivery_errors: true
}