Permalink
Browse files

Added automatic decoding of base64 bodies #1214 [Jamis Buck]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1275 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent c8bd316 commit a2eb744dfbd53f1b7117834201957f60181ad78f @dhh dhh committed May 2, 2005
Showing with 19 additions and 1 deletion.
  1. +2 −0 actionmailer/CHANGELOG
  2. +3 −1 actionmailer/lib/action_mailer/base.rb
  3. +14 −0 actionmailer/test/mail_service_test.rb
View
@@ -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]
@@ -181,7 +181,9 @@ def quote_any_address_if_necessary(charset, *args)
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
@@ -73,6 +73,14 @@ def utf8_body(recipient)
@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 @@ def test_multiple_utf8_recipients
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

0 comments on commit a2eb744

Please sign in to comment.