class Twelvefactor::Environment::Mailer::Smtp

Public Class Methods

apply(app, mailer_url) click to toggle source
# File lib/twelvefactor/environment/mailer/smtp.rb, line 5
def self.apply app, mailer_url
  config = app.config
  config.action_mailer.delivery_method = :smtp
  config.action_mailer.smtp_settings = smtp_settings mailer_url
end
basic_settings(url) click to toggle source
# File lib/twelvefactor/environment/mailer/smtp.rb, line 17
def self.basic_settings url
  {
    address: url.host,
    port: url.port,
    user_name: url.user && URI.unescape(url.user),
    password: url.password && URI.unescape(url.password)
  }
end
extra_settings(query) click to toggle source
# File lib/twelvefactor/environment/mailer/smtp.rb, line 26
def self.extra_settings query
  return {} unless query

  CGI
    .parse(query)
    .map { |k, val| [k.to_sym, val.first] }
    .to_h
end
smtp_settings(url) click to toggle source
# File lib/twelvefactor/environment/mailer/smtp.rb, line 11
def self.smtp_settings url
  basic_settings(url)
    .merge(extra_settings(url.query))
    .compact
end