提供 HTML 与纯文本两份视图模版。
在开发环境下应显示发信失败错误。这些错误默认是关闭的。
-
# config/environments/development.rb
config.action_mailer.smtp_settings = {
address: 'localhost',
port: 1025,
}
为域名设置默认项。
若需要在邮件中添加到网站的超链接,应总是使用 方法,而非
_path
方法。_url
方法产生的超链接包含域名,而_path
方法产生相对链接。# 差
You can always find more info about this course
<%= link_to 'here', course_path() %>
<%= link_to 'here', course_url(@course) %>
确保测试环境下的 email 发送方法设置为
test
:# config/environments/test.rb
config.action_mailer.delivery_method = :test
开发环境和生产环境下的发送方法应设置为
smtp
: