Merge pull request #6914 from adullact/feature/6871-enable-mailcatcher
Support de MailCatcher dans l'environnement de production
This commit is contained in:
commit
cec9aea93e
3 changed files with 22 additions and 2 deletions
|
@ -90,11 +90,17 @@ SENDINBLUE_BALANCING="disabled"
|
||||||
SENDINBLUE_BALANCING_VALUE="50"
|
SENDINBLUE_BALANCING_VALUE="50"
|
||||||
|
|
||||||
# Alternate SMTP Provider: Mailtrap (mail catcher for staging environments)
|
# Alternate SMTP Provider: Mailtrap (mail catcher for staging environments)
|
||||||
# When enabled, all emails will be sent using this provided
|
# When enabled, all emails will be sent using this provider
|
||||||
MAILTRAP_ENABLED="disabled"
|
MAILTRAP_ENABLED="disabled"
|
||||||
MAILTRAP_USERNAME=""
|
MAILTRAP_USERNAME=""
|
||||||
MAILTRAP_PASSWORD=""
|
MAILTRAP_PASSWORD=""
|
||||||
|
|
||||||
|
# Alternative SMTP Provider: Mailcatcher (Catches mail and serves it through a dream.)
|
||||||
|
# When enabled, all emails will be sent using this provider
|
||||||
|
MAILCATCHER_ENABLED="disabled"
|
||||||
|
MAILCATCHER_HOST=""
|
||||||
|
MAILCATCHER_PORT=""
|
||||||
|
|
||||||
# External service: live chat for admins (specific to démarches-simplifiées.fr)
|
# External service: live chat for admins (specific to démarches-simplifiées.fr)
|
||||||
CRISP_ENABLED="disabled"
|
CRISP_ENABLED="disabled"
|
||||||
CRISP_CLIENT_KEY=""
|
CRISP_CLIENT_KEY=""
|
||||||
|
|
|
@ -89,7 +89,8 @@ Rails.application.configure do
|
||||||
|
|
||||||
elsif ENV['SENDINBLUE_ENABLED'] == 'enabled'
|
elsif ENV['SENDINBLUE_ENABLED'] == 'enabled'
|
||||||
config.action_mailer.delivery_method = :sendinblue
|
config.action_mailer.delivery_method = :sendinblue
|
||||||
|
elsif ENV['MAILCATCHER_ENABLED'] == 'enabled'
|
||||||
|
config.action_mailer.delivery_method = :mailcatcher
|
||||||
else
|
else
|
||||||
config.action_mailer.delivery_method = :mailjet
|
config.action_mailer.delivery_method = :mailjet
|
||||||
end
|
end
|
||||||
|
|
13
config/initializers/mailcatcher.rb
Normal file
13
config/initializers/mailcatcher.rb
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
if ENV.fetch('MAILCATCHER_ENABLED') == 'enabled'
|
||||||
|
ActiveSupport.on_load(:action_mailer) do
|
||||||
|
module Mailcatcher
|
||||||
|
class SMTP < ::Mail::SMTP; end
|
||||||
|
end
|
||||||
|
|
||||||
|
ActionMailer::Base.add_delivery_method :mailcatcher, Mailcatcher::SMTP
|
||||||
|
ActionMailer::Base.mailcatcher_settings = {
|
||||||
|
address: ENV.fetch("MAILCATCHER_HOST"),
|
||||||
|
port: ENV.fetch("MAILCATCHER_PORT")
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in a new issue