aboutsummaryrefslogtreecommitdiffstats
path: root/lib/mail_handler/backends
diff options
context:
space:
mode:
Diffstat (limited to 'lib/mail_handler/backends')
-rw-r--r--lib/mail_handler/backends/mail_backend.rb9
-rw-r--r--lib/mail_handler/backends/tmail_backend.rb13
2 files changed, 22 insertions, 0 deletions
diff --git a/lib/mail_handler/backends/mail_backend.rb b/lib/mail_handler/backends/mail_backend.rb
index 6a5fff13f..a6f2a6a44 100644
--- a/lib/mail_handler/backends/mail_backend.rb
+++ b/lib/mail_handler/backends/mail_backend.rb
@@ -13,6 +13,15 @@ module MailHandler
Mail.new(data)
end
+ # Extracts all attachments from the given TNEF file as a Mail object
+ def mail_from_tnef(content)
+ main = Mail.new
+ tnef_attachments(content).each do |attachment|
+ main.add_file(attachment)
+ end
+ main.ready_to_send!
+ main
+ end
end
end
end \ No newline at end of file
diff --git a/lib/mail_handler/backends/tmail_backend.rb b/lib/mail_handler/backends/tmail_backend.rb
index fc675c1ed..4daa5469f 100644
--- a/lib/mail_handler/backends/tmail_backend.rb
+++ b/lib/mail_handler/backends/tmail_backend.rb
@@ -18,6 +18,19 @@ module MailHandler
mail
end
+ # Extracts all attachments from the given TNEF file as a TMail::Mail object
+ def mail_from_tnef(content)
+ main = TMail::Mail.new
+ main.set_content_type 'multipart', 'mixed', { 'boundary' => TMail.new_boundary }
+ tnef_attachments(content).each do |attachment|
+ tmail_attachment = TMail::Mail.new
+ tmail_attachment['content-location'] = attachment[:filename]
+ tmail_attachment.body = attachment[:content]
+ main.parts << tmail_attachment
+ end
+ main
+ end
+
end
end
end \ No newline at end of file