Sample code to send a utf-8 string in subject line of email. Its pretty simple and straight forward

 

def send_to_lead(lead_email, from_email, from_name, offer_id, club_id, customer_id)
@customer_name = from_name
@customer_email = from_email
str = “期待很快就可!”
#    str= “subject in english”
subject=str
if str[0..1]==”&#”
subject_raw = str.gsub(“&#”,””).gsub(“!”,””).split(“;”)
subject=””
subject_raw.each {|t| subject += [t.to_i].pack(“U*”)}
end
mail(:to => lead_email,
:from => “\””+from_name+”\”” + “<“+from_email+”>”,
:charset => ‘utf-8’,
:subject => subject,
:reply_to => ‘noreply@buddyreferralsystem.com’,
:content_type =>’multipart/alternative’,
:content_transfer_encoding => ‘8bit’,
“X-Mailer” => “Ruby (1.9.2)”
).deliver
end

Convert utf-8 to chinese in ruby on rails

Leave a Reply

Your email address will not be published.