Class: Mail::Gpg::EncryptedPart

Inherits:
Part
  • Object
show all
Defined in:
lib/mail/gpg/encrypted_part.rb

Constant Summary collapse

CONTENT_TYPE =
'application/octet-stream'

Instance Method Summary collapse

Constructor Details

#initialize(cleartext_mail, options = {}) ⇒ EncryptedPart

options are:

:signers : sign using this key (give the corresponding email address) :password: passphrase for the signing key :recipients : array of receiver addresses :keys : A hash mapping recipient email addresses to public keys or public key ids. Imports any keys given here that are not already part of the local keychain before sending the mail. :always_trust : send encrypted mail to untrusted receivers, true by default



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/mail/gpg/encrypted_part.rb', line 16

def initialize(cleartext_mail, options = {})
  options = { always_trust: true }.merge options

  encrypted = GpgmeHelper.encrypt(cleartext_mail.encoded, options)
  super() do
    body encrypted.to_s
    content_type "#{CONTENT_TYPE}; name=\"encrypted.asc\""
    content_disposition 'inline; filename="encrypted.asc"'
    content_description 'OpenPGP encrypted message'
  end
end