gpt4 book ai didi

ruby-on-rails - Rails ActionMailer 不会从控制台发送

转载 作者:行者123 更新时间:2023-12-02 00:56:31 24 4
gpt4 key购买 nike

我已经阅读了所有其他 SO 答案,但我仍然无法解决这个问题。

鉴于我的 RewardMailer 定义了以下电子邮件:

# A test email to check up on the configurations
def test_mail
@recipients = 'aminshahgilani@gmail.com'
@from = 'postmaster@sandboxXXXXXXXXXXXXXXXXX.mailgun.org'
@subject = 'test from the Rails Console'
@body = 'This is a test email'
end

我的 config/environments/development.rb 文件包含:

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: 'smtp.mailgun.org',
port: 587,
domain: 'sandboxXXXXXXXXXXXXXXXXX.mailgun.org',
user_name: 'postmaster@sandboxXXXXXXXXXXXXXXXXX.mailgun.org',
password: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
authentication: :plain
}

当我从 Rails 控制台检查时,我通过以下方式确认配置:

Rails.application.config.action_mailer
=> {:perform_deliveries=>true, :raise_delivery_errors=>true, :delivery_method=>:smtp, :smtp_settings=>{:address=>"smtp.mailgun.org", :port=>587, :domain=>"sandbox0574dfb215d14874ac51fb9f9052131b.mailgun.org", :user_name=>"postmaster@sandboxXXXXXXXXXXXXXXXXX.mailgun.org", :password=>"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", :authentication=>:plain}, :assets_dir=>"/home/gilani/Sandbox/mailman/public", :javascripts_dir=>"/home/gilani/Sandbox/mailman/public/javascripts", :stylesheets_dir=>"/home/gilani/Sandbox/mailman/public/stylesheets", :preview_path=>"/home/gilani/Sandbox/mailman/test/mailers/previews", :asset_host=>nil, :relative_url_root=>nil}

为什么以下内容无法送达我的电子邮件?或者完全显示任何错误

RewardMailer.test_mail().deliver_now

RewardMailer#test_mail: processed outbound mail in 0.1ms
=> nil

我也检查了我的 Mailgun 日志,没有。日志是空的!

最佳答案

您没有在 test_mail 中调用 mail 方法。

关于ruby-on-rails - Rails ActionMailer 不会从控制台发送,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34445433/

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