Refactor mailer options usage
This commit is contained in:
parent
c4c2d16342
commit
339462f320
@ -1,4 +1,5 @@
|
|||||||
class ApplicationMailer < ActionMailer::Base
|
class ApplicationMailer < ActionMailer::Base
|
||||||
|
default Rails.application.config.action_mailer.default_options
|
||||||
layout 'mailer'
|
layout 'mailer'
|
||||||
|
|
||||||
private
|
private
|
||||||
@ -19,7 +20,7 @@ class ApplicationMailer < ActionMailer::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def from_address
|
def from_address
|
||||||
ENV.fetch('SMTP_FROM_ADDRESS', 'accounts@localhost')
|
self.class.default[:from]
|
||||||
end
|
end
|
||||||
|
|
||||||
def from_domain
|
def from_domain
|
||||||
|
@ -57,16 +57,22 @@ Rails.application.configure do
|
|||||||
# routes, locales, etc. This feature depends on the listen gem.
|
# routes, locales, etc. This feature depends on the listen gem.
|
||||||
config.file_watcher = ActiveSupport::EventedFileUpdateChecker
|
config.file_watcher = ActiveSupport::EventedFileUpdateChecker
|
||||||
|
|
||||||
config.action_mailer.default_options = {
|
|
||||||
from: "accounts@localhost"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Don't actually send emails, cache them for viewing via letter opener
|
# Don't actually send emails, cache them for viewing via letter opener
|
||||||
config.action_mailer.delivery_method = :letter_opener
|
config.action_mailer.delivery_method = :letter_opener
|
||||||
|
|
||||||
# Don't care if the mailer can't send
|
# Don't care if the mailer can't send
|
||||||
config.action_mailer.raise_delivery_errors = true
|
config.action_mailer.raise_delivery_errors = true
|
||||||
|
|
||||||
# Base URL to be used by email template link helpers
|
# Base URL to be used by email template link helpers
|
||||||
config.action_mailer.default_url_options = { host: "localhost:3000", protocol: "http" }
|
config.action_mailer.default_url_options = {
|
||||||
|
host: "localhost:3000",
|
||||||
|
protocol: "http"
|
||||||
|
}
|
||||||
|
|
||||||
|
config.action_mailer.default_options = {
|
||||||
|
from: "accounts@localhost",
|
||||||
|
message_id: -> { "<#{Mail.random_tag}@localhost>" },
|
||||||
|
}
|
||||||
|
|
||||||
# Allow requests from any IP
|
# Allow requests from any IP
|
||||||
config.web_console.permissions = '0.0.0.0/0'
|
config.web_console.permissions = '0.0.0.0/0'
|
||||||
|
@ -63,7 +63,7 @@ Rails.application.configure do
|
|||||||
outgoing_email_domain = Mail::Address.new(outgoing_email_address).domain
|
outgoing_email_domain = Mail::Address.new(outgoing_email_address).domain
|
||||||
|
|
||||||
config.action_mailer.default_url_options = {
|
config.action_mailer.default_url_options = {
|
||||||
host: ENV['AKKOUNTS_DOMAIN'],
|
host: ENV.fetch('AKKOUNTS_DOMAIN'),
|
||||||
protocol: "https",
|
protocol: "https",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,8 +46,12 @@ Rails.application.configure do
|
|||||||
|
|
||||||
config.action_mailer.default_url_options = {
|
config.action_mailer.default_url_options = {
|
||||||
host: "accounts.kosmos.org",
|
host: "accounts.kosmos.org",
|
||||||
protocol: "https",
|
protocol: "https"
|
||||||
from: "accounts@kosmos.org"
|
}
|
||||||
|
|
||||||
|
config.action_mailer.default_options = {
|
||||||
|
from: "accounts@kosmos.org",
|
||||||
|
message_id: -> { "<#{Mail.random_tag}@kosmos.org>" },
|
||||||
}
|
}
|
||||||
|
|
||||||
config.active_job.queue_adapter = :test
|
config.active_job.queue_adapter = :test
|
||||||
|
Loading…
x
Reference in New Issue
Block a user