From 5ddffc8c24635fe44cd66f78d7b5e2f7091e34d6 Mon Sep 17 00:00:00 2001 From: Jamis Buck Date: Fri, 1 Jul 2005 13:17:44 +0000 Subject: Allow for nested parts in multipart mails #1570 [Flurin Egger] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1581 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionmailer/lib/action_mailer/part_container.rb | 25 ++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 actionmailer/lib/action_mailer/part_container.rb (limited to 'actionmailer/lib/action_mailer/part_container.rb') diff --git a/actionmailer/lib/action_mailer/part_container.rb b/actionmailer/lib/action_mailer/part_container.rb new file mode 100644 index 0000000000..57ad2f5157 --- /dev/null +++ b/actionmailer/lib/action_mailer/part_container.rb @@ -0,0 +1,25 @@ +module ActionMailer + module PartContainer + attr_reader :parts + + # Add a part to a multipart message, with the given content-type. The + # part itself is yielded to the block, so that other properties (charset, + # body, headers, etc.) can be set on it. + def part(params) + params = {:content_type => params} if String === params + part = Part.new(params) + yield part if block_given? + @parts << part + end + + # Add an attachment to a multipart message. This is simply a part with the + # content-disposition set to "attachment". + def attachment(params, &block) + params = { :content_type => params } if String === params + params = { :disposition => "attachment", + :transfer_encoding => "base64" }.merge(params) + part(params, &block) + end + + end +end -- cgit v1.2.3