mirror of
https://github.com/Fishwaldo/huginn.git
synced 2025-03-15 19:31:26 +00:00
moving mail config into an initializer and a config/smtp.yml file
This commit is contained in:
parent
f8744cb89a
commit
9874e2b41a
5 changed files with 52 additions and 28 deletions
|
@ -39,13 +39,5 @@ Huginn::Application.configure do
|
|||
config.action_mailer.perform_deliveries = false # Enable when testing!
|
||||
config.action_mailer.raise_delivery_errors = true
|
||||
config.action_mailer.delivery_method = :smtp
|
||||
config.action_mailer.smtp_settings = {
|
||||
address: ENV['SMTP_SERVER'] || 'smtp.gmail.com',
|
||||
port: ENV['SMTP_PORT'] || 587,
|
||||
domain: ENV['SMTP_DOMAIN'],
|
||||
authentication: ENV['SMTP_AUTHENTICATION'] || 'plain',
|
||||
enable_starttls_auto: ENV['SMTP_ENABLE_STARTTLS_AUTO'] == 'true' ? true : false,
|
||||
user_name: ENV['SMTP_USER_NAME'],
|
||||
password: ENV['SMTP_PASSWORD']
|
||||
}
|
||||
# smtp_settings moved to config/initializers/action_mailer.rb
|
||||
end
|
||||
|
|
|
@ -66,16 +66,11 @@ Huginn::Application.configure do
|
|||
|
||||
config.action_mailer.default_url_options = { :host => ENV['DOMAIN'] }
|
||||
config.action_mailer.asset_host = ENV['DOMAIN']
|
||||
if ENV['ASSET_HOST']
|
||||
config.action_mailer.asset_host = ENV['ASSET_HOST']
|
||||
end
|
||||
config.action_mailer.perform_deliveries = true
|
||||
config.action_mailer.raise_delivery_errors = true
|
||||
config.action_mailer.delivery_method = :smtp
|
||||
config.action_mailer.smtp_settings = {
|
||||
address: ENV['SMTP_SERVER'] || 'smtp.gmail.com',
|
||||
port: ENV['SMTP_PORT'] || 587,
|
||||
domain: ENV['SMTP_DOMAIN'],
|
||||
authentication: ENV['SMTP_AUTHENTICATION'] || 'plain',
|
||||
enable_starttls_auto: ENV['SMTP_ENABLE_STARTTLS_AUTO'] == 'true' ? true : false,
|
||||
user_name: ENV['SMTP_USER_NAME'],
|
||||
password: ENV['SMTP_PASSWORD']
|
||||
}
|
||||
# smtp_settings moved to config/initializers/action_mailer.rb
|
||||
end
|
|
@ -66,16 +66,11 @@ Huginn::Application.configure do
|
|||
|
||||
config.action_mailer.default_url_options = { :host => ENV['DOMAIN'] }
|
||||
config.action_mailer.asset_host = ENV['DOMAIN']
|
||||
if ENV['ASSET_HOST']
|
||||
config.action_mailer.asset_host = ENV['ASSET_HOST']
|
||||
end
|
||||
config.action_mailer.perform_deliveries = true
|
||||
config.action_mailer.raise_delivery_errors = true
|
||||
config.action_mailer.delivery_method = :smtp
|
||||
config.action_mailer.smtp_settings = {
|
||||
address: ENV['SMTP_SERVER'] || 'smtp.gmail.com',
|
||||
port: ENV['SMTP_PORT'] || 587,
|
||||
domain: ENV['SMTP_DOMAIN'],
|
||||
authentication: ENV['SMTP_AUTHENTICATION'] || 'plain',
|
||||
enable_starttls_auto: ENV['SMTP_ENABLE_STARTTLS_AUTO'] == 'true' ? true : false,
|
||||
user_name: ENV['SMTP_USER_NAME'],
|
||||
password: ENV['SMTP_PASSWORD']
|
||||
}
|
||||
end
|
||||
# smtp_settings moved to config/initializers/action_mailer.rb
|
||||
end
|
||||
|
|
16
config/initializers/action_mailer.rb
Normal file
16
config/initializers/action_mailer.rb
Normal file
|
@ -0,0 +1,16 @@
|
|||
# Read smtp config out of a config/smtp.yml file
|
||||
|
||||
smtp_config = YAML::load(ERB.new(File.read(Rails.root.join('config', 'smtp.yml'))).result)
|
||||
if smtp_config.keys.include? Rails.env
|
||||
Huginn::Application.config.action_mailer.smtp_settings = smtp_config[Rails.env].symbolize_keys
|
||||
end
|
||||
|
||||
# Huginn::Application.config.action_mailer.smtp_settings = {
|
||||
# address: ENV['SMTP_SERVER'] || 'smtp.gmail.com',
|
||||
# port: ENV['SMTP_PORT'] || 587,
|
||||
# domain: ENV['SMTP_DOMAIN'],
|
||||
# authentication: ENV['SMTP_AUTHENTICATION'] || 'plain',
|
||||
# enable_starttls_auto: ENV['SMTP_ENABLE_STARTTLS_AUTO'] == 'true' ? true : false,
|
||||
# user_name: ENV['SMTP_USER_NAME'],
|
||||
# password: ENV['SMTP_PASSWORD']
|
||||
# }
|
26
config/smtp.yml
Normal file
26
config/smtp.yml
Normal file
|
@ -0,0 +1,26 @@
|
|||
development:
|
||||
address: <%= ENV['SMTP_SERVER'] || "smtp.gmail.com" %>
|
||||
port: <%= ENV['SMTP_PORT'] || 587 %>
|
||||
domain: <%= ENV['SMTP_DOMAIN'] %>
|
||||
authentication: <%= ENV['SMTP_AUTHENTICATION'] || "plain" %>
|
||||
enable_starttls_auto: <%= ENV['SMTP_ENABLE_STARTTLS_AUTO'] == 'true' ? true : false %>
|
||||
user_name: <%= ENV['SMTP_USER_NAME'] || "" %>
|
||||
password: <%= ENV['SMTP_PASSWORD'] || "" %>
|
||||
|
||||
staging:
|
||||
address: <%= ENV['SMTP_SERVER'] || "smtp.gmail.com" %>
|
||||
port: <%= ENV['SMTP_PORT'] || 587 %>
|
||||
domain: <%= ENV['SMTP_DOMAIN'] %>
|
||||
authentication: <%= ENV['SMTP_AUTHENTICATION'] || "plain" %>
|
||||
enable_starttls_auto: <%= ENV['SMTP_ENABLE_STARTTLS_AUTO'] == 'true' ? true : false %>
|
||||
user_name: <%= ENV['SMTP_USER_NAME'] || "" %>
|
||||
password: <%= ENV['SMTP_PASSWORD'] || "" %>
|
||||
|
||||
production:
|
||||
address: <%= ENV['SMTP_SERVER'] || "smtp.gmail.com" %>
|
||||
port: <%= ENV['SMTP_PORT'] || 587 %>
|
||||
domain: <%= ENV['SMTP_DOMAIN'] %>
|
||||
authentication: <%= ENV['SMTP_AUTHENTICATION'] || "plain" %>
|
||||
enable_starttls_auto: <%= ENV['SMTP_ENABLE_STARTTLS_AUTO'] == 'true' ? true : false %>
|
||||
user_name: <%= ENV['SMTP_USER_NAME'] || "" %>
|
||||
password: <%= ENV['SMTP_PASSWORD'] || "" %>
|
Loading…
Add table
Reference in a new issue