diff options
-rw-r--r-- | actionmailer/CHANGELOG | 2 | ||||
-rw-r--r-- | actionmailer/lib/action_mailer/base.rb | 4 | ||||
-rwxr-xr-x | actionmailer/test/mail_service_test.rb | 14 |
3 files changed, 19 insertions, 1 deletions
diff --git a/actionmailer/CHANGELOG b/actionmailer/CHANGELOG index 88c3548046..25c980803b 100644 --- a/actionmailer/CHANGELOG +++ b/actionmailer/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Added automatic decoding of base64 bodies #1214 [Jamis Buck] + * Added that delivery errors are caught in a way so the mail is still returned whether the delivery was successful or not * Fixed that email address like "Jamis Buck, M.D." <wild.medicine@example.net> would cause the quoter to generate emails resulting in "bad address" errors from the mail server #1220 [Jamis Buck] diff --git a/actionmailer/lib/action_mailer/base.rb b/actionmailer/lib/action_mailer/base.rb index faade19e9e..9afe5138d9 100644 --- a/actionmailer/lib/action_mailer/base.rb +++ b/actionmailer/lib/action_mailer/base.rb @@ -181,7 +181,9 @@ module ActionMailer #:nodoc: def receive(raw_email) logger.info "Received mail:\n #{raw_email}" unless logger.nil? - new.receive(TMail::Mail.parse(raw_email)) + mail = TMail::Mail.parse(raw_email) + mail.base64_decode + new.receive(mail) end private diff --git a/actionmailer/test/mail_service_test.rb b/actionmailer/test/mail_service_test.rb index b5d488a02b..04fa6bde1f 100755 --- a/actionmailer/test/mail_service_test.rb +++ b/actionmailer/test/mail_service_test.rb @@ -73,6 +73,14 @@ class TestMailer < ActionMailer::Base @body = "åœö blah" @charset = "utf-8" end + + class <<self + attr_accessor :received_body + end + + def receive(mail) + self.class.received_body = mail.body + end end TestMailer.template_root = File.dirname(__FILE__) + "/fixtures" @@ -307,5 +315,11 @@ EOF assert_match(/\nTo: =\?utf-8\?Q\?Foo_.*?\?= <extended@example.net>, Example Recipient <me/, created.encoded) end + def test_receive_decodes_base64_encoded_mail + fixture = File.read(File.dirname(__FILE__) + "/fixtures/raw_email") + TestMailer.receive(fixture) + assert_match(/Jamis/, TestMailer.received_body) + end + end |