Khi tôi chạy bưu phẩm của tôi trong chế độ phát triển, tôi nhận được lỗi sau:Rails 4: Net :: ReadTimeout khi gọi ActionMailer
Net::ReadTimeout in SchoolApplicationsController#create
Dưới đây là phương pháp điều khiển mà là nhận được thời gian chờ
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
Tôi rất tích cực khi xảy ra lỗi do cuộc gọi NotificationsMailer
vì khi Tôi nhận xét, tôi không còn gặp lỗi nữa.
Đây là bưu phẩm của tôi, và các cài đặt:
class NotificationsMailer < ActionMailer::Base
default :from => "[email protected]"
default :to => "[email protected]"
def send_application(application)
@application = application
mail(:subject => "New Application")
end
end
Dưới đây là các thiết lập environments/development.rb
smtp của tôi:
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
Khi tôi viết ENV['fls_username']
trong Rails console Tôi nhận được giá trị đúng. Cùng với mật khẩu. Tên người dùng có định dạng [email protected] Có đúng hay đúng định dạng "người dùng" và tên miền được ngụ ý từ thông số domain
?
Có vẻ như 'tls: true' là khóa. Tôi không tin những thay đổi khác quan trọng. (Cũng lưu ý nó là 'tls', không phải' tsl'.) –
Tôi xác nhận, vì tôi đã thêm 'tls: true'. – mwangi
điều này cũng có tác dụng đối với tôi, nhưng tôi ước tôi có một giờ cuối cùng trong đời. –