diff --git a/lib/mail/network/retriever_methods/imap.rb b/lib/mail/network/retriever_methods/imap.rb index 0b3e30127..f99391b12 100644 --- a/lib/mail/network/retriever_methods/imap.rb +++ b/lib/mail/network/retriever_methods/imap.rb @@ -179,6 +179,8 @@ def start(config=Mail::Configuration.instance, &block) imap.authenticate(settings[:authentication], settings[:user_name], settings[:password]) end + imap.enable :utf8 if imap.capable?("ENABLE") + yield imap ensure if defined?(imap) && imap && !imap.disconnected? diff --git a/spec/mail/network/retriever_methods/imap_spec.rb b/spec/mail/network/retriever_methods/imap_spec.rb index 1f1f54eae..71429cd77 100644 --- a/spec/mail/network/retriever_methods/imap_spec.rb +++ b/spec/mail/network/retriever_methods/imap_spec.rb @@ -318,5 +318,18 @@ end end + + describe "UTF8=ACCEPT support" do + before(:each) do + @imap = MockIMAP.new + allow(MockIMAP).to receive(:new).and_return(@imap) + allow(@imap).to receive(:capable?).with("ENABLE").and_return(true) + end + it "should enable UTF8=ACCEPT" do + expect(@imap).to receive(:enable).with(:utf8) + messages = Mail.find + end + end + end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 4a43170b8..7ca431532 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -319,6 +319,10 @@ def expunge @@marked_for_deletion = [] end + def capable?(name) + false + end + def self.mailbox; @@mailbox end # test only def self.readonly?; @@readonly end # test only