我想使用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 }
我的呼叫如下所示:
OrderMailer.send_new_order(@order).deliver
最后生成的控制器如下所示:
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
当然还有邮件捕获器的运行。那为什么不发邮件呢?
发布于 2012-09-26 17:20:24
我发现,我为开发环境使用了错误的SMTP地址。
它必须是
config.action_mailer.smtp_settings = { :address => "127.0.0.1", :port => 1025 }
而不是
config.action_mailer.smtp_settings = { :address => "localhost", :port => 1025 }
发布于 2015-09-22 06:43:47
https://github.com/sj26/mailcatcher/issues/182
$ mailcatcher -f -v
Starting MailCatcher
==> smtp://127.0.0.1:1025
==> http://127.0.0.1:1080
==> SMTP: Received message from '<donotreply@xxx.com>' (676 bytes)
https://stackoverflow.com/questions/12554909
复制相似问题