Skip to content

Commit

Permalink
Added ":text_part_charset" option for multi part mail.
Browse files Browse the repository at this point in the history
  • Loading branch information
yoshuki committed Jun 2, 2011
1 parent b57a33c commit 42dac28
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/pony.rb
Expand Up @@ -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

Expand Down
5 changes: 5 additions & 0 deletions spec/pony_spec.rb
Expand Up @@ -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'
Expand Down

0 comments on commit 42dac28

Please sign in to comment.