简体   繁体   English

Rails ActionMailer不会从控制台发送

[英]Rails ActionMailer won't send from console

I've read all the other SO answers, but I still can't fix this. 我已经阅读了所有其他的答案,但是仍然无法解决。

Given my RewardMailer has the following email defined: 鉴于我的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

And that my config/environments/development.rb file contains: 我的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
}

And when I check from the Rails console, I confirm the configuration with: 当我从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}

Why does the following not deliver my email? 为什么以下内容不发送我的电子邮件? Or show any error for it at all 或者完全显示任何错误

RewardMailer.test_mail().deliver_now

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

I checked with my Mailgun logs as well, nothing. 我也检查了我的Mailgun日志,什么也没有。 The logs are empty! 日志是空的!

您不是在test_mail中调用mail方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM