Sha256: 4c16e588bda5d49c9d535d057240501bc9b90af23d89d64906a5c92016978ffc

Contents?: true

Size: 546 Bytes

Versions: 3

Compression:

Stored size: 546 Bytes

Contents

module Mailsafe
  class RerouteInterceptor
    def self.delivering_email(message)
      unless Mailsafe.override_receiver.blank?
        message.subject = "[#{receivers(message)}] #{message.subject}"
        message.to = Mailsafe.override_receiver
        message.cc = []
        message.bcc = []
      end
    end

    private

    def self.receivers(message)
      [ :to, :cc, :bcc ].map do |rec_type|
        recs = message.send(rec_type)
        "#{rec_type}: #{recs.join ', '}" if recs.present?
      end.compact.join '; '
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mailsafe-0.3.1 lib/mailsafe/reroute_interceptor.rb
mailsafe-0.3.0 lib/mailsafe/reroute_interceptor.rb
mailsafe-0.2.1 lib/mailsafe/reroute_interceptor.rb