Method: CMS::FormsMailer#fix_mixed_attachments

Defined in:
app/mailers/cms/forms_mailer.rb

#fix_mixed_attachmentsObject

[View source]

28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'app/mailers/cms/forms_mailer.rb', line 28

def fix_mixed_attachments
  # do nothing if we have no actual attachments
  return if @_message.parts.select { |p| p.attachment? && !p.inline? }.none?

  mail = Mail.new

  related = Mail::Part.new
  related.content_type = @_message.content_type
  @_message.parts.select { |p| !p.attachment? || p.inline? }.each { |p| related.add_part(p) }
  mail.add_part related

  mail.header       = @_message.header.to_s
  mail.bcc          = @_message.header[:bcc].value # copy bcc manually because it is omitted in header.to_s
  mail.content_type = nil
  @_message.parts.select { |p| p.attachment? && !p.inline? }.each { |p| mail.add_part(p) }

  @_message = mail
  wrap_delivery_behavior!(delivery_method.to_sym)
end