From 42dac2818771536a7999000597dcf339a1920736 Mon Sep 17 00:00:00 2001 From: MIKAMI Yoshiyuki Date: Fri, 3 Jun 2011 01:54:38 +0900 Subject: [PATCH] Added ":text_part_charset" option for multi part mail. --- lib/pony.rb | 4 ++++ spec/pony_spec.rb | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/lib/pony.rb b/lib/pony.rb index 689614f..974dbc4 100644 --- a/lib/pony.rb +++ b/lib/pony.rb @@ -219,6 +219,10 @@ def self.build_mail(options) mail.charset = options[:charset] if options[:charset] # charset must be set after setting content_type + if mail.multipart? && options[:text_part_charset] + mail.text_part.charset = options[:text_part_charset] + end + mail end diff --git a/spec/pony_spec.rb b/spec/pony_spec.rb index 6d60881..06087bc 100644 --- a/spec/pony_spec.rb +++ b/spec/pony_spec.rb @@ -82,6 +82,11 @@ mail.charset.should == 'UTF-8' end + it "text_part_charset" do + mail = Pony.build_mail(:attachments => {"foo.txt" => "content of foo.txt"}, :body => 'test', :text_part_charset => 'ISO-2022-JP') + mail.text_part.charset.should == 'ISO-2022-JP' + end + it "default charset" do Pony.build_mail(:body => 'body').charset.should == 'UTF-8' Pony.build_mail(:body => 'body', :content_type => 'text/html').charset.should == 'UTF-8'