demarches-normaliennes/config/initializers/sendinblue.rb
Pierre de La Morinerie 847abca122 config: simplify mailer configuration again
Move everything to initializers, and replace the email settings
interceptor by a BalancerDeliveryMethod.

It has the advantage that it can be configured entirely from the
`config/environment.rb` file, without an extra file to look at.
2022-02-08 12:44:43 +01:00

23 lines
717 B
Ruby

if ENV.fetch('SENDINBLUE_ENABLED') == 'enabled'
require 'sib-api-v3-sdk'
ActiveSupport.on_load(:action_mailer) do
module Sendinblue
class SMTP < ::Mail::SMTP; end
end
ActionMailer::Base.add_delivery_method :sendinblue, Sendinblue::SMTP
ActionMailer::Base.sendinblue_settings = {
user_name: Rails.application.secrets.sendinblue[:username],
password: Rails.application.secrets.sendinblue[:smtp_key],
address: 'smtp-relay.sendinblue.com',
domain: 'smtp-relay.sendinblue.com',
port: '587',
authentication: :cram_md5
}
end
SibApiV3Sdk.configure do |config|
config.api_key['api-key'] = Rails.application.secrets.sendinblue[:api_v3_key]
end
end