require 'mail' require 'mapi/msg' require 'mapi/convert' module Mail class Message # The behaviour of the 'to' and 'cc' methods have changed # between TMail and Mail; this monkey-patching restores the # TMail behaviour. The key difference is that when there's an # invalid address, e.g. ' leaf.url_part_number, :content_type => get_content_type(leaf), :filename => get_part_file_name(leaf), :charset => leaf.charset, :within_rfc822_subject => within_rfc822_subject, :body => body, :hexdigest => Digest::MD5.hexdigest(body) } attachments << leaf_attributes end return attachments 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).to_s end address = Mail::Address.new address.display_name = name address.address = email address.to_s end def address_from_string(string) mail = Mail.new mail.from = string mail.from[0] end end end end