intercity / intercity-next

Web control panel to deploy apps on your servers (with Dokku)
https://intercity.io/
MIT License
116 stars 23 forks source link

From address SMTP setting isn't dynamically loaded #212

Open michiels opened 8 years ago

michiels commented 8 years ago

We have the SMTP settings functionality that allows a user to load SMTP settings from the database. This way people are able to dynamically configure the sending mail server for their Intercity instance.

In case of the "from email" setting, this is currently nog working properly. The setting is loaded at the class level in ApplicationMailer, which only gets loaded when the app or sidekiq worker starts up. This is a problem for first-use users, that have a blank from email setting when the Sidekiq service it started on the first run. Because of the class-level code, the email from setting is never updated, unless you restart the running Sidekiq service or full Intercity container.

This is the conflicting code:

class ApplicationMailer < ActionMailer::Base
  default from: Setting.get(:from_email)

This code is not executed on a per-email basis, but only on app boot. So we should either see if we can execute it in a proc:

class ApplicationMailer < ActionMailer::Base
  default from: -> { Setting.get(:from_email) }

Or find some other way of setting the "from" per-email, instead of as the ApplicationMailers default