使用导轨 2.3.14
我的电子邮件 erb:data.html.erb:
<% @data.each do |error| %>
<table>
<% error.each_pair do |k, v| %>
<tr>
<td>
<%= k %>
</td>
<td>
<%= ap v %>
</td>
</tr>
<% end %>
</table>
<br />
<% end %>
我可以收到电子邮件,但是当我收到时,它会显示为纯文本,而不是呈现 HTML。
动作邮件配置:
config.action_mailer.raise_delivery_errors = true
# Send emails during development
config.action_mailer.perform_deliveries = true
ActionMailer::Base.delivery_method = :sendmail
更新:必须在我的交付方式中指定内容类型:
def data(data, sent_at = Time.now)
Time.zone = 'Eastern Time (US & Canada)'
content_type 'text/html'
subject "[#{RAILS_ENV}] An error has occurred - #{Time.now.to_s("%B %d, %Y")}"
recipients "bugs@mydomain.com"
from AppConfig['from_email']
sent_on sent_at
@body = {:data => data}
end