How to handle UTF-8 email headers (like Subject:) using Ruby?

前端 未结 3 775
旧时难觅i
旧时难觅i 2021-01-05 04:04

I\'m an email n00b but I am working on an application that sends HTML email with Unicode characters (as my friend noted \"enjoy encoding hell\").

The Subject:<

3条回答
  •  礼貌的吻别
    2021-01-05 04:10

    Ahah! ActionMailer::Quoting has a quoted_printable method.

    So here's what I did:

    def my_email(foo)
      ...
      @subject = quoted_printable(foo.some_subject_with_accented_chars, 'utf-8')
      ...
    end
    

    Doing this convinced Mail.app to display the rest of the email using UTF-8. Now to test the rest!

提交回复
热议问题