ActionMailer和开发模式,它可以写入文件或什么?
我想在本地测试我的注册过程(开发模式),我如何测试电子邮件将如何发送和呈现等?
我不是指unit testing或集成测试,而只是在开发我的应用程序并进入注册页面等时。我希望它发送电子邮件但发送到不使用smtp的文件。
这可能吗?
我有什么选择?
这可以在config/environments/*.rb
文件中配置。
# output to tmp/mails directory config.action_mailer.delivery_method = :file # ... and to specify output location # config.action_mailer.file_settings = { :location => Rails.root.join('tmp/mail') }
详细信息可以在Action Mailer Basics的配置部分或ActionMailer :: Base API中找到
Rails 4.2 :file
传递方法源和Mail :: FileDelivery源
通过在浏览器中自动打开文件(当然在开发环境中), LetterOpener使您更简单地预览刚发送的电子邮件。
我意识到你说你想在手动测试的环境中检查电子邮件,但似乎值得一提的是这些类型的测试可以自动化。 email_spec是我以前用过的一个gem。
- Rails 3:nested_form,collection_select,accepts_nested_attributes_for和fields_for
- Rails 4.1.1 w / pg_search – “PG :: SyntaxError:ERROR:AS”或附近的语法错误“”