gpt4 book ai didi

ruby-on-rails - Rails 4:调用 ActionMailer 时的 Net::ReadTimeout

转载 作者:行者123 更新时间:2023-12-03 22:50:28 26 4
gpt4 key购买 nike

在开发模式下运行邮件程序时,出现以下错误:

Net::ReadTimeout in SchoolApplicationsController#create
这是获取超时的 Controller 方法
  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

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 => "from@slf.net"
default :to => "nayr@slf.net"

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: 'secure3309.hostgator.com',
port: 465,
domain: 'slf.net',
ssl: true,
user_name: ENV['slf_username'],
password: ENV['slf_password'],
authentication: 'plain',
enable_starttls_auto: true }
end
当我写 ENV['slf_username']在 Rails 控制台中,我得到了正确的值。和密码一样。用户名的格式为 user@slf.net。这是正确的还是正确的格式只是“用户”并且域隐含于 domain范围?

最佳答案

看完这篇 post我再次查看了我的 smtp 设置并添加了

tls: true 

改变了
port: 465port: '465'因为我注意到大多数人把它写成一个字符串。也同样改变了字符串 "plain"到符号 :plain

关于ruby-on-rails - Rails 4:调用 ActionMailer 时的 Net::ReadTimeout,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26166032/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com