1

I would like to use Sendinblue to send transactional email from my Ruby on Rails web application via SMTP. I edited config/environments/production.rb as follows:

ActionMailer::Base.smtp_settings = {
  :address => 'smtp-relay.sendinblue.com',
  :port => '587',
  :authentication => :plain,
  :user_name => ???,
  :password => ???,
  :domain => 'fireworks.com',
  :enable_starttls_auto => true
}

What am I expected to use as user_name and password? My account's username and password or my SMTP keys? Also, am I required to use any gem, like sib-api-v3-sdk, or this gem is useful only for sending email using the Sendinblue API?

Asarluhi
  • 1,280
  • 3
  • 22
  • 43
  • 1
    You can find your password and username in the settings tab on the sendinblue site. No, you don't need an additional gem to send mails with SMTP. Rails does not care what SMTP server you're using. But I would really consider using the API instead of SMTP. – max Jan 19 '20 at 17:11
  • In the settings tab there are only general settings, like timezone. – Asarluhi Jan 19 '20 at 17:28

3 Answers3

6

Simply go to your SendInBlue account's API page and use the the username and password found there.

https://account.sendinblue.com/advanced/api

Other answers suggest to use gems that are not required for SMTP. You DO NOT need the sendinblue or sib-api-v3-sdk gems to use SIB with ActionMailer in a plain vanilla Rails app.

#config/environments/production.rb

config.action_mailer.delivery_method = :smtp

config.action_mailer.smtp_settings = {
  :address        => ENV.fetch('SMTP_HOST', 'smtp-relay.sendinblue.com'),
  :port           => ENV.fetch('SMTP_PORT', '587'),
  :authentication => :plain,
  :user_name      => ENV['SMTP_USERNAME'], #See: https://account.sendinblue.com/advanced/api
  :password       => ENV['SMTP_PASSWORD'], #See: https://account.sendinblue.com/advanced/api
  :enable_starttls_auto => true
}
danielricecodes
  • 3,446
  • 21
  • 23
0

Add this to your gemfile

gem 'sib-api-v3-sdk'

Add this to config/environments/production.rb

  config.action_mailer.default_url_options = { host: "your_domain.com", port: 587 }
  config.action_mailer.delivery_method = :smtp
  config.action_mailer.smtp_settings = {
    :address => "smtp-relay.sendinblue.com",
    :port => 587,
    :user_name => ENV['SEND_IN_BLUE_USERNAME'],
    :password => ENV['SEND_IN_BLUE_PASSWORD'],
    :authentication => 'login',
    :enable_starttls_auto => true
  }

Add this in in config/initializers/send_in_blue.rb

SibApiV3Sdk.configure do |config|
  config.api_key['api-key'] = ENV["SEND_IN_BLUE_API_KEY"]
end

Make sure your environment variables are correct. It works for me in production.

don_Bigote
  • 896
  • 7
  • 33
-1

can add gem 'sendinblue'Official Sendinblue provided API V2 Ruby GEM

In order to send an email, you need to change the smtp settings in config/environments/*.rb(Whichever applicable)

Rails.application.configure do
  #append this settings
  config.action_mailer.raise_delivery_errors = true
  config.action_mailer.perform_deliveries = true
  config.action_mailer.delivery_method = :smtp
  config.action_mailer.smtp_settings = {
    :address => ‘smtp-relay.sendinblue.com’,
    :port => 587,
    :user_name => ‘YOUR_SENDINBLUE_EMAIL’,
    :password => ‘YOUR_SENDINBLUE_PASSWORD’,
    :authentication => ‘login’,
    :enable_starttls_auto => true
  }
end

change STMP & API in Your setting account

STMP SERVER --> smtp-relay.sendinblue.com
port --> 587
Community
  • 1
  • 1
  • I have the same problem and this is not working for me either. I get `ArgumentError: SMTP-AUTH requested but missing secret phrase` in `/app/vendor/ruby-2.6.0/lib/ruby/2.6.0/net/smtp.rb:780:in `check_auth_args'`. Any idea? – Leticia Esperon Mar 16 '20 at 14:09
  • 1
    You don't need the gem when using SMTP authentication. – danielricecodes Nov 11 '21 at 16:28