Module: MailAlternativesWithAttachments::ActionMailerPrepareMessage
- Defined in:
- lib/mail_alternatives_with_attachments/action_mailer_prepare_message.rb
Instance Method Summary collapse
-
#prepare_message(headers = {}, &block) ⇒ Object
Copied directly from ActionMailer::Base#mail but without the automatic rendering of templates.
Instance Method Details
#prepare_message(headers = {}, &block) ⇒ Object
Copied directly from ActionMailer::Base#mail but without the automatic rendering of templates.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/mail_alternatives_with_attachments/action_mailer_prepare_message.rb', line 5 def (headers = {}, &block) return @_message if @_mail_was_called && headers.blank? && !block @_mail_was_called = true m = @_message # At the beginning, do not consider class default for content_type content_type = headers[:content_type] # Call all the procs (if any) default_values = {} self.class.default.each do |k,v| default_values[k] = v.is_a?(Proc) ? instance_eval(&v) : v end # Handle defaults headers = headers.reverse_merge(default_values) headers[:subject] ||= default_i18n_subject # Apply charset at the beginning so all fields are properly quoted m.charset = charset = headers[:charset] # Set configure delivery behavior wrap_delivery_behavior!(headers.delete(:delivery_method), headers.delete(:delivery_method_options)) # Assign all headers except parts_order, content_type and body assignable = headers.except(:parts_order, :content_type, :body, :template_name, :template_path) assignable.each { |k, v| m[k] = v } # Setup content type, reapply charset and handle parts order m.content_type = set_content_type(m, content_type, headers[:content_type]) m.charset = charset if m.multipart? m.body.set_sort_order(headers[:parts_order]) m.body.sort_parts! end m end |