当前位置:  开发笔记 > 编程语言 > 正文

Rails ActionMailer不会从控制台发送

如何解决《RailsActionMailer不会从控制台发送》经验,为你挑选了1个好方法。

我已经阅读了所有其他的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日志,没有.日志是空的!



1> archana..:

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

推荐阅读
雯颜哥_135
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有