【发布时间】:2016-01-27 07:32:58
【问题描述】:
在我们的 Rails 3.2 应用程序中,我们有以下设置来预览电子邮件:
examples_controller
def registration
mail = EventMailer.registration(registration: EventRegistration.last, cache_email: false)
return render_mail(mail)
end
event_mailer.rb
def registration(options = {})
@registration = options[:registration]
@event = Event.find(@registration.event_id)
@subject = options[:subject] || 'Your Learn Registration'
return_email = mail(to: @registration.email, subject: @subject)
# the email if we got it
return_email
end
我们刚刚添加了电子邮件的文本版本,所以现在在 app/views/event_mailer 我们有registration.html.erb 和registration.text.erb。在添加电子邮件的文本版本之前,用户可以浏览到 /webmail/examples/registration 并查看电子邮件的 html 版本。添加文本电子邮件后,它就坏了。
关于如何解决此问题的想法?我尝试在示例控制器中将 multipart 设置为 false,但这不起作用。
另外,这里是 render_mail 方法...
def render_mail(mail)
# send it through the inline style processing
inlined_content = InlineStyle.process(mail.body.to_s,ignore_linked_stylesheets: true)
render(:text => inlined_content, :layout => false)
end
【问题讨论】:
标签: ruby-on-rails ruby-on-rails-3 email