當我在開發模式下運行我的郵件時,我收到以下錯誤:軌道4:網:: ReadTimeout調用的ActionMailer
Net::ReadTimeout in SchoolApplicationsController#create
這裏是越來越超時
def create
@school_application = SchoolApplication.new(school_application_params)
@school_application.program_cost = @school_application.calculate_cost_to_charge(params[:school_application][:program], params[:school_application][:duration])
if @school_application.save
Rails.logger.debug("Hey mufugga")
NotificationsMailer.send_application(@school_application).deliver
redirect_to application_path(@school_application.id)
else
Rails.logger.debug(@school_application.errors.full_messages)
@school_application.errors.full_messages.each do |msg|
flash.now[:error] = msg
end
render action: "new"
end
end
控制器方法
我的積極的錯誤是由NotificationsMailer
調用引起的,因爲當我註釋掉 時,我不會再出錯。
這裏是我的郵件,並設置:
class NotificationsMailer < ActionMailer::Base
default :from => "[email protected]"
default :to => "[email protected]"
def send_application(application)
@application = application
mail(:subject => "New Application")
end
end
這裏是我的environments/development.rb
SMTP設置:
Fls::Application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the web server when you make code changes.
config.cache_classes = false
# Do not eager load code on boot.
config.eager_load = false
# Show full error reports and disable caching.
config.consider_all_requests_local = true
config.action_controller.perform_caching = false
# Don't care if the mailer can't send.
# Print deprecation notices to the Rails logger.
config.active_support.deprecation = :log
# Raise an error on page load if there are pending migrations
config.active_record.migration_error = :page_load
# Debug mode disables concatenation and preprocessing of assets.
# This option may cause significant delays in view rendering with a large
# number of complex assets.
config.assets.debug = true
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: 'secure3209.hostgator.com',
port: 465,
domain: 'fls.net',
ssl: true,
user_name: ENV['fls_username'],
password: ENV['fls_password'],
authentication: 'plain',
enable_starttls_auto: true }
end
當我在Rails的控制檯寫ENV['fls_username']
我得到正確的值。與密碼相同。用戶名格式爲[email protected]。這是正確的還是正確的格式只是「用戶」,並且該域暗含domain
參數?
看起來'tls:true'是關鍵。我不相信其他變化很重要。 (還要注意它是'tls',而不是'tsl'。) – 2014-11-15 06:16:37
我確認,爲我添加'tls:true'工作。 – mwangi 2016-08-18 13:46:06
這也適用於我,但我希望我有我生命中的最後一個小時。 – 2017-10-04 01:26:54