Skip to content
This repository has been archived by the owner on Apr 17, 2023. It is now read-only.

Commit

Permalink
Allow us to turn off smtp authentication.
Browse files Browse the repository at this point in the history
  • Loading branch information
jmahowald committed Sep 29, 2016
1 parent 4ac49c4 commit d837160
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions config/initializers/smtp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,25 @@

if defined?(APP_CONFIG) && APP_CONFIG["email"]["smtp"]["enabled"]
Portus::Application.config.action_mailer.delivery_method = :smtp

smtp = APP_CONFIG["email"]["smtp"]
ActionMailer::Base.smtp_settings = {
smtp_settings = {
address: smtp["address"],
port: smtp["port"],
user_name: smtp["user_name"],
password: smtp["password"],
domain: smtp["domain"],
authentication: :login,
enable_starttls_auto: true
enable_starttls_auto: false
}
if smtp["user_name"].blank?
Rails.logger.info "No smtp username supplied, not using smtp authentication"
else
auth_settings = {
user_name: smtp["user_name"],
password: smtp["password"],
authentication: :login,
enable_starttls_auto: true
}
smtp_settings = smtp_settings.merge(auth_settings)
end
ActionMailer::Base.smtp_settings = smtp_settings
else
# If SMTP is not enabled, then go for sendmail.
Portus::Application.config.action_mailer.delivery_method = :sendmail
Expand Down

0 comments on commit d837160

Please sign in to comment.