如何修复异常通知错误,并发送一封信

时间:2016-12-14 19:07:30

标签: ruby-on-rails ruby

当我通过Exception Notification gem向Postoffice发送信件时出现错误,并且生产中没有发送信件:

Error: An error occurred when sending a notification using 'email' notifier. Net::SMTPFatalError: 550 <example@exmple.com>, Recipient unknown

本地通过Letter Opener一切正常。

1 个答案:

答案 0 :(得分:1)

你确定它是Postoffice而不是postman吗?

  

邮局

     

Rails gem验证各种世界邮政和邮政编码的格式,

如果是邮递员,你应该查看你的作品.rb:

#config/environments/production.rb
...

config.action_mailer.raise_delivery_errors = true
config.action_mailer.default_url_options = { :host => 'example.com' }
config.action_mailer.perform_deliveries = true
ActionMailer::Base.smtp_settings = {
  :port           => '25', # or 2525
  :address        => ENV['POSTMARK_SMTP_SERVER'],
  :user_name      => ENV['POSTMARK_API_TOKEN'],
  :password       => ENV['POSTMARK_API_TOKEN'],
  :domain         => 'example.com',
  :authentication => :cram_md5, # or :plain for plain-text authentication
  :enable_starttls_auto => true, # or false for unencrypted connection
}
ActionMailer::Base.delivery_method = :smtp

...