当前位置: 动力学知识库 > 问答 > 编程问答 >

ruby on rails - How to make Sendgrid emails use a common layout

问题描述:

My rails app uses sendgrid to send emails. I wanted to know if there was anyway for all the emails to use a common layout. I tried setting the layout in the notifications controller but the layout was not being applied to the emails.

网友答案:

I don't think this is specific to SendGrid. If you are using their SMTP interface then you don't need to do anything additional over sending a normal email in Rails.

To use layouts in emails you specify the layout in a very similar fashion to a normal controller. This guide should help. Importantly note:

The layout name needs to be the same as your mailer, such as user_mailer.html.erb and user_mailer.text.erb to be automatically recognized by your mailer as a layout.

网友答案:

Try to follow these precautions of sendgrid http://support.sendgrid.com/entries/21699742-HTML-Formatting-Issues may be it resolve your issue, otherwise its very simple to make a layout for all emails, for this you just have to mention layout in mailer class.

分享给朋友:
您可能感兴趣的文章:
随机阅读: