ActionMailer和开发模式,它可以写入文件或什么?

时间:2023-01-16 10:18:56

I want to test my registration process locally (development mode), how can I test how emails will be sent out and rendered etc?

我想在本地测试我的注册过程(开发模式),我如何测试电子邮件将如何发送和呈现等?

I am not referring to a unit-test or integration test, but just while developing my app and going on the register page etc. I want it to send out the emails but to a file not using smtp.

我不是指单元测试或集成测试,而只是在开发我的应用程序并进入注册页面等时。我希望它发送电子邮件但发送到不使用smtp的文件。

Is this possible?

这可能吗?

What options do I have?

我有什么选择?

3 个解决方案

#1


41  

This is configurable in the config/environments/*.rb files.

这可以在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') }

Detailed information can be found in the config section of Action Mailer Basics or on ActionMailer::Base API

详细信息可以在Action Mailer Basics的配置部分或ActionMailer :: Base API中找到


Rails 4.2 :file delivery method source and Mail::FileDelivery source

Rails 4.2:文件传递方法源和Mail :: FileDelivery源

#2


7  

LetterOpener makes it even simpler for you to preview the emails you just sent by opening the file in the browser automatically (in development environment of course).

通过在浏览器中自动打开文件(当然在开发环境中),LetterOpener使您更简单地预览刚发送的电子邮件。

#3


0  

I realize you said you want to check emails in the context of manual testing, but it seems worth mentioning that these sorts of tests can be automated. email_spec is one gem i've used to do it.

我意识到你说你想在手动测试的环境中检查电子邮件,但似乎值得一提的是这些类型的测试可以自动化。 email_spec是我以前用过的一个宝石。

#1


41  

This is configurable in the config/environments/*.rb files.

这可以在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') }

Detailed information can be found in the config section of Action Mailer Basics or on ActionMailer::Base API

详细信息可以在Action Mailer Basics的配置部分或ActionMailer :: Base API中找到


Rails 4.2 :file delivery method source and Mail::FileDelivery source

Rails 4.2:文件传递方法源和Mail :: FileDelivery源

#2


7  

LetterOpener makes it even simpler for you to preview the emails you just sent by opening the file in the browser automatically (in development environment of course).

通过在浏览器中自动打开文件(当然在开发环境中),LetterOpener使您更简单地预览刚发送的电子邮件。

#3


0  

I realize you said you want to check emails in the context of manual testing, but it seems worth mentioning that these sorts of tests can be automated. email_spec is one gem i've used to do it.

我意识到你说你想在手动测试的环境中检查电子邮件,但似乎值得一提的是这些类型的测试可以自动化。 email_spec是我以前用过的一个宝石。