blob: 0e198adf0b9a2c75c9e460505ac1be731fc4292d (
plain)
1
2
3
4
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
45
46
47
48
49
50
51
|
require 'mail'
module MailHandler
module Backends
module MailBackend
def backend()
'Mail'
end
# Note that the decode flag is not yet used
def mail_from_raw_email(data, decode=true)
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
# Return a copy of the file name for the mail part
def get_part_file_name(mail_part)
part_file_name = mail_part.filename
part_file_name.nil? ? nil : part_file_name.dup
end
# Format
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"
end
if name.nil?
return Mail::Address.new(email)
end
address = Mail::Address.new
address.display_name = name
address.address = email
address.to_s
end
def address_from_string(string)
Mail::Address.new(string).address
end
end
end
end
|