3

I'm trying to send an email with Chinese/Taiwan characters in the subject line. The user entered email content shows up correctly in Chinese, but I'm having problems with the subject line.

I'm using Rails 3.0.9 and have it configured to send through my Gmail account right now. All of that is working, but maybe Google is messing with my subject line?

Here's the code snippet in my mailer:

mail(:to => lead_email,
     :subject => "=?utf-8?B?" + Base64.encode64(@club.offers.first.title) + "?=",
     :from => from_email,
     :content_type => "text/html; charset=utf-8",
     :reply_to => 'noreply@buddyreferralsystem.com',
     :content_transfer_encoding => '8bit'
).deliver

and this is what I get in my email headers when it is received.

Subject: 期待很快就可以在俱樂部看到你喔!
Mime-Version: 1.0
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

When I read the email in GMail, I see the non-readable subject line above, but the chinese text in the email content is rendered just fine. One thing to note is that the Content-Transfer-Encoding seems to be getting changed from the '8bit' that I set to 'quoted-printable'.

How should I get Chinese characters to show up in the subject line instead of the 期 ?

junhan
  • 119
  • 4
  • 11
John Goodsen
  • 101
  • 5

1 Answers1

1

Try using different charsets? In your header it says the Content-Type is UTF-8 in your subject line.

Try changing that to some other charset like big5

GB is the official standard of the People's Republic of China, and Big5 is a de facto standard of Taiwan.

Put 'big5' where you see 'utf-8' in the subject line there:

mail(:to => lead_email,
     :subject => "=?utf-8?B?" + Base64.encode64(@club.offers.first.title) + "?=",
     :from => from_email,
     :content_type => "text/html; charset=big5",
     :reply_to => 'noreply@buddyreferralsystem.com',
     :content_transfer_encoding => '8bit'
).deliver

http://en.wikipedia.org/wiki/Big5

Eric Leschinski
  • 146,994
  • 96
  • 417
  • 335