Skip to content

Instantly share code, notes, and snippets.

@mccraigmccraig
Created October 21, 2010 15:24
Show Gist options
  • Save mccraigmccraig/638672 to your computer and use it in GitHub Desktop.
Save mccraigmccraig/638672 to your computer and use it in GitHub Desktop.
mail fails to decode encoded addresses
>> puts m.to_s
Date: Thu, 21 Oct 2010 16:28:20 +0100
From: craig mcmillan <[email protected]>
To: =?UTF-8?B?ImNyYWlnIOaXpeacrOWbvSI=?= <[email protected]>
Message-ID: <[email protected]>
Subject: =?UTF-8?Q?big_in_=E6=97=A5=E6=9C=AC=E5=9B=BD?=
Mime-Version: 1.0
Content-Type: text/plain;
charset=UTF-8;
format=flowed
Content-Transfer-Encoding: base64
User-Agent: Postbox 2.0.1 (Macintosh/20101011)
VW5pY29kZSBib2R5IGlzIGJpZyBpbiDml6XmnKzlm70=
=> nil
>> m.subject
=> "big in 日本国"
>> m.body.to_s
=> "Unicode body is big in 日本国"
>> m[:to].tree.addresses.first.name
=> "=?UTF-8?B?ImNyYWlnIOaXpeacrOWbvSI=?="
>> Mail::Encodings.decode_encode(m[:to].tree.addresses.first.name, :decode)
=> ""craig 日本国""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment