Dan*_*idt 1 actionmailer ruby-on-rails-3
我想使用mailcatcher来检查我的邮件是否已发送.他们不是,我想知道为什么,因为邮件生成并且肯定被称为.
所以在我的config/enviroment/development.rb中我写道:
config.action_mailer.raise_delivery_errors = true
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = { :address => "localhost", :port => 1025 }
Run Code Online (Sandbox Code Playgroud)
我的电话看起来像这样:
OrderMailer.send_new_order(@order).deliver
Run Code Online (Sandbox Code Playgroud)
最后生成的控制器如下:
class OrderMailer < ActionMailer::Base
default from: "from@example.com"
def send_new_order(order)
@greeting = "Hi"
mail to: "to@example.org", subject: "Test"
end
end
Run Code Online (Sandbox Code Playgroud)
邮件当然是邮件运行的.那邮件为什么不发送?
Dan*_*idt 13
我发现,我使用错误的SMTP地址进行开发环境.
它必须是
config.action_mailer.smtp_settings = { :address => "127.0.0.1", :port => 1025 }
Run Code Online (Sandbox Code Playgroud)
代替
config.action_mailer.smtp_settings = { :address => "localhost", :port => 1025 }
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3583 次 |
| 最近记录: |