1
0

action_mailer.rb 943 B

12345678910111213141516171819202122
  1. ActionMailer::Base.smtp_settings = {}.tap { |config|
  2. config[:address] = ENV['SMTP_SERVER'] || 'smtp.gmail.com'
  3. config[:port] = ENV['SMTP_PORT']&.to_i || 587
  4. config[:domain] = ENV['SMTP_DOMAIN']
  5. authentication = ENV['SMTP_AUTHENTICATION'].presence || 'plain'
  6. user_name = ENV['SMTP_USER_NAME'].presence || 'none'
  7. if authentication != 'none' && user_name != 'none'
  8. config[:authentication] = authentication
  9. config[:user_name] = user_name
  10. config[:password] = ENV['SMTP_PASSWORD'].presence
  11. end
  12. config[:enable_starttls_auto] = ENV['SMTP_ENABLE_STARTTLS_AUTO'] == 'true'
  13. config[:ssl] = ENV['SMTP_SSL'] == 'true'
  14. config[:openssl_verify_mode] = ENV['SMTP_OPENSSL_VERIFY_MODE'].presence
  15. config[:ca_path] = ENV['SMTP_OPENSSL_CA_PATH'].presence
  16. config[:ca_file] = ENV['SMTP_OPENSSL_CA_FILE'].presence
  17. config[:read_timeout] = ENV['SMTP_READ_TIMEOUT']&.to_i
  18. config[:open_timeout] = ENV['SMTP_OPEN_TIMEOUT']&.to_i
  19. }