gpt4 book ai didi

ruby-on-rails - 超时::在本地服务器上使用 ActionMailer 时出错

转载 作者:数据小太阳 更新时间:2023-10-29 08:13:15 25 4
gpt4 key购买 nike

我正在尝试在我的 Rails 应用程序中设置电子邮件操作,并且我想在本地测试邮件功能。我关注了this Railscast但是每当我尝试发送邮件时,发送邮件都会引发 Timeout::Error(execution expired) 错误。

config/environments/development.rb

  config.action_mailer.delivery_method = :smtp
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = true

config/initializers/setup_mail.rb

ActionMailer::Base.smtp_settings = {
:address => 'smtp.gmail.com',
:port => 587,
:domain => 'recipes.dev',
:user_name => 'myemail@gmail.com',
:password => '*******',
:authentication => 'plain',
:enable_starttls_auto => true
}

ma​​ilers/user_mailer.rb

class UserMailer < ActionMailer::Base
default from: "myemail@gmail.com"

def test_email(user)
@email = user.email
@name = user.name
mail(:to => @email, :subject => 'test e-mail')
end
end

controllers/users_controller.rb

UserMailer.test_email(@user).deliver

如有任何帮助,我们将不胜感激。

最佳答案

尝试将您的 smpt_setting 端 development.rb 设置为:

config.action_mailer.smtp_settings = {
:address => 'smtp.gmail.com',
:port => 587,
:domain => 'recipes.dev',
:user_name => 'myemail@gmail.com',
:password => '*******',
:authentication => 'plain',
:enable_starttls_auto => true
}

你不需要 setup_mail.rb

请看http://guides.rubyonrails.org/action_mailer_basics.html#example-action-mailer-configuration

关于ruby-on-rails - 超时::在本地服务器上使用 ActionMailer 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11142897/

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