From b0f14073742cfdbe9b85b61f6ff0f30f1296c748 Mon Sep 17 00:00:00 2001 From: Manson Wang Date: Wed, 5 Feb 2014 18:06:23 +0800 Subject: [PATCH] Fix system-email page and ActionMailer configuration, now gmail is working fine --- app/mailer/cron_mail.rb | 40 ++++++++++++----------- app/views/admin/sites/preference.html.erb | 4 +-- config/environments/production.rb | 10 ------ 3 files changed, 23 insertions(+), 31 deletions(-) diff --git a/app/mailer/cron_mail.rb b/app/mailer/cron_mail.rb index bda1d06..c769b23 100644 --- a/app/mailer/cron_mail.rb +++ b/app/mailer/cron_mail.rb @@ -2,28 +2,30 @@ class CronMail < ActionMailer::Base default :from => "orbit_test@rulingcom.com" def get_settings - # @@smtp_settings = { - # :address => "smtp.gmail.com", - # :port => '587', - # :domain => "smtp.gmail.com", - # :authentication => "plain", - # :user_name => "redmine@rulingcom.com", - # :password => "rulingredmine", - # :tls => true, - # :enable_starttls_auto => true - # } - @@smtp_settings = { - :address => @site['mail_settings']['address'], - :port => @site['mail_settings']['port'], - :domain => @site['mail_settings']['domain'], - :authentication => @site['mail_settings']['authentication'], - :user_name => @site['mail_settings']['user_name'], - :password => @site['mail_settings']['password'], - :tls => @site['mail_settings']['tls'], - :enable_starttls_auto => @site['mail_settings']['enable_starttls_auto'] + @site = Site.first + @@smtp_settings = { + :enable_starttls_auto => @site['site_settings']['enable_starttls_auto'], + :address => @site['site_settings']['address'], + :port => @site['site_settings']['port'], + :domain => @site['site_settings']['domain'], + :authentication => @site['site_settings']['authentication'], + :user_name => @site['site_settings']['user_name'], + :password => @site['site_settings']['password'] } end + def self.smtp_settings + @site = Site.first + @@smtp_settings = { + :enable_starttls_auto => @site['site_settings']['enable_starttls_auto'], + :address => @site['site_settings']['address'], + :port => @site['site_settings']['port'], + :domain => @site['site_settings']['domain'], + :authentication => @site['site_settings']['authentication'], + :user_name => @site['site_settings']['user_name'], + :password => @site['site_settings']['password'] + } + end def time_check(msg) get_settings diff --git a/app/views/admin/sites/preference.html.erb b/app/views/admin/sites/preference.html.erb index 991a03b..8407bcd 100644 --- a/app/views/admin/sites/preference.html.erb +++ b/app/views/admin/sites/preference.html.erb @@ -65,7 +65,7 @@
- <%= f.text_field :port, :value => (@site['site_settings']['port'] rescue nil), :class=>"input-large", :placeholder=>"Domain" %> + <%= f.text_field :domain, :value => (@site['site_settings']['domain'] rescue nil), :class=>"input-large", :placeholder=>"Domain" %>
@@ -83,7 +83,7 @@
- <%= f.text_field :password, :value => (@site['site_settings']['password'] rescue nil), :class=>"input-large", :placeholder=>"Password" %> + <%= f.password_field :password, :value => (@site['site_settings']['password'] rescue nil), :class=>"input-large", :placeholder=>"Password" %>
diff --git a/config/environments/production.rb b/config/environments/production.rb index 307b249..1ca0668 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -63,15 +63,5 @@ Orbit::Application.configure do config.action_mailer.delivery_method = :smtp config.action_mailer.perform_deliveries = true config.action_mailer.raise_delivery_errors = true - config.action_mailer.smtp_settings = { - :enable_starttls_auto => true, - :openssl_verify_mode => 'none', - :address => 'smtp.sendgrid.net', - :port => '587', - :domain => "new.tp.rulingcom.com", - :authentication => "plain", - :user_name => "rulingcom", - :password => "bjo4xjp6" - } end