Converting External CSS to Inline CSS for Mail in Rails

前端 未结 3 678
遇见更好的自我
遇见更好的自我 2021-01-31 20:30

I am trying to create an application that will send out style-heavy emails and have required clients working except Google\'s Gmail. I researched the issue and it looks like Gma

3条回答
  •  遇见更好的自我
    2021-01-31 21:30

    Added premailer:

    def premailer(message)
      message.text_part.body = Premailer.new(message.text_part.body.to_s, with_html_string: true).to_plain_text
      message.html_part.body = Premailer.new(message.html_part.body.to_s, with_html_string: true).to_inline_css
    
      return message
    end
    
    def welcome(user)
      @user = user
    
      message = mail ...
    end
    

提交回复
热议问题