lib/autoheathen/email_processor.rb
# Forward the email to sender, with decoded documents replacing the originals
Forward the email to sender, with decoded documents replacing the originals
Forward the email to sender with decoded documents replacing the originals
def deliver_onward email, documents, mail_to
      logger.info "Sending response mail to #{mail_to}"
      email.cc [] 
      email.to mail_to
      email.subject "#{'Fwd: ' unless email.subject.to_s.start_with? 'Fwd:'}#{email.subject}"
      email.return_path email.from unless email.return_path
      email.message_id = nil 
      good_headers = ONWARD_HEADERS.map{ |h| h.downcase }
      inspect_headers = email.header.map(&:name)
      inspect_headers .each do |name|
        unless good_headers.include? name.downcase
          email.header[name] = nil
        end
      end
      email.received = nil 
      email.parts.delete_if { |p| p.attachment? }
      documents.each do |doc|
        if doc[:content]
          email.add_file filename: doc[:filename], content: doc[:content]
        else 
          email.add_file filename: doc[:orig_filename], content: doc[:orig_content]
        end
      end
      email.delivery_method :smtp, address: @cfg[:mail_host], port: @cfg[:mail_port]
      deliver email
    end
def deliver_onward email , documents , mail_to logger . info "Sending response mail to #{mail_to}" email . cc [ ] email . to mail_to email . subject "#{'Fwd: ' unless email.subject.to_s.start_with? 'Fwd:'}#{email.subject}" email . return_path email . from unless email . return_path email . message_id = nil good_headers = ONWARD_HEADERS . map { | h | h . downcase } inspect_headers = email . header . map ( & :name ) inspect_headers . each do | name | unless good_headers . include? name . downcase email . header [ name ] = nil end end email . received = nil email . parts . delete_if { | p | p . attachment? } documents . each do | doc | if doc [ :content ] email . add_file filename : doc [ :filename ] , content : doc [ :content ] else email . add_file filename : doc [ :orig_filename ] , content : doc [ :orig_content ] end end email . delivery_method :smtp , address : @cfg [ :mail_host ] , port : @cfg [ :mail_port ] deliver email end
Forward the email to sender, with decoded documents replacing the originals
Forward the email to sender with decoded documents replacing the originals
# No CCing, just send to the recipient # something weird goes on with Sharepoint, where the doc is dropped on the floor # so, remove any offending headers # make sure of message_id too # make sure of received # replace attachments with converted files # preserve non-converted attachments when forwarding
email
<not_specific>
documents
<not_specific>
mail_to
<not_specific>