Class: Dkim::Interceptor

Inherits:
Object
  • Object
show all
Defined in:
lib/dkim/interceptor.rb

Class Method Summary collapse

Class Method Details

.delivering_email(message) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/dkim/interceptor.rb', line 4

def self.delivering_email(message)
  require 'mail/dkim_field'

  # strip any existing signatures
  if message['DKIM-Signature']
    warn "WARNING: Dkim::Interceptor given a message with an existing signature, which it has replaced."
    warn "If you really want to add a second signature to the message, you should be using the dkim gem directly."
    message['DKIM-Signature'] = nil
  end

  # generate new signature
  dkim_signature = SignedMail.new(message.encoded).dkim_header.value

  # prepend signature to message
  message.header.fields.unshift Mail::DkimField.new(dkim_signature)
  message
end