diff options
author | Louise Crow <louise.crow@gmail.com> | 2012-12-04 14:13:49 +0000 |
---|---|---|
committer | Louise Crow <louise.crow@gmail.com> | 2012-12-04 14:13:49 +0000 |
commit | 096c5c5613f426f2e5a73618e6a4e41bc06b57e2 (patch) | |
tree | 56834ba4aaf2b8551e8cf8398cc5d5efcc35ef59 /lib | |
parent | 1d42085da0a439f51770e7816feeb949b936380e (diff) |
Adding methods for getting the content type of a mail part, and getting header strings from a mail.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/mail_handler/backends/mail_backend.rb | 8 | ||||
-rw-r--r-- | lib/mail_handler/backends/tmail_backend.rb | 8 |
2 files changed, 16 insertions, 0 deletions
diff --git a/lib/mail_handler/backends/mail_backend.rb b/lib/mail_handler/backends/mail_backend.rb index aeca75ec5..8dd2e6b48 100644 --- a/lib/mail_handler/backends/mail_backend.rb +++ b/lib/mail_handler/backends/mail_backend.rb @@ -94,6 +94,14 @@ module MailHandler mail['auto-submitted'] ? mail['auto-submitted'].value : nil end + def get_content_type(part) + part.content_type ? part.content_type.split(';')[0] : nil + end + + def get_header_string(header, mail) + mail.header[header] ? mail.header[header].to_s : nil + end + # Format def address_from_name_and_email(name, email) if !MySociety::Validate.is_valid_email(email) diff --git a/lib/mail_handler/backends/tmail_backend.rb b/lib/mail_handler/backends/tmail_backend.rb index e725f7e9f..4b7291d00 100644 --- a/lib/mail_handler/backends/tmail_backend.rb +++ b/lib/mail_handler/backends/tmail_backend.rb @@ -75,6 +75,14 @@ module MailHandler mail['auto-submitted'] ? mail['auto-submitted'].body : nil end + def get_content_type(part) + part.content_type + end + + def get_header_string(header, mail) + mail.header_string(header) + end + def address_from_name_and_email(name, email) if !MySociety::Validate.is_valid_email(email) raise "invalid email " + email + " passed to address_from_name_and_email" |