jkraemer / mail-gpg

GPG/MIME extension for the Ruby Mail Library
MIT License
69 stars 24 forks source link

Rails integration issue when encrypting with users public key #64

Closed krtschmr closed 4 years ago

krtschmr commented 4 years ago

my mailer received an override

def mail(args)
    if current_user&.want_encrypted_mails?
      args[:gpg] = {encrypt: true, keys: {current_user.email => current_user.account_setting.pgp_public_key} }
    end
    super(args)
  end

quick verification of the args hash

{:to=>"test@test.de",
 :subject=>"Test mail",
 :template_path=>"mailers/deposit_mailer",
 :gpg=>
  {:encrypt=>true,
   :keys=>
    {"test@test.de"=>
      "-----BEGIN PGP PUBLIC KEY BLOCK-----\r\nmQIN......................PN\r\n=KIA3\r\n-----END PGP PUBLIC KEY BLOCK-----"}}}

so this seem to look correct. however if i inspect the email, mail.body.encoded it's all in plaintext.

what am i missing or what am i doing wrong?

krtschmr commented 4 years ago

Update:

since a user on reddit pointed it out: mail.body.encoded is always plain and only becomes encrypted if the mail is actually send out.

maybe we can change the docs accordingly