Send unencrypted replies if encryption fails
authorMarius Gavrilescu <marius@ieval.ro>
Mon, 7 Jul 2014 09:23:36 +0000 (12:23 +0300)
committerMarius Gavrilescu <marius@ieval.ro>
Mon, 7 Jul 2014 09:23:36 +0000 (12:23 +0300)
lib/App/EdwardNG.pm

index 256cf7d670d7031697918d079edeca7cc0805f8c..08b50eb827865e4b1e155cf2cee6f414dd605703 100644 (file)
@@ -129,9 +129,11 @@ sub run {
                Subject => 'Re: ' . $in->get('Subject'),
                Data    => $data);
 
                Subject => 'Re: ' . $in->get('Subject'),
                Data    => $data);
 
+       my $email_unencrypted = $email->dup;
        my $mg = mg always_trust => 1;
        my $mg = mg always_trust => 1;
-       $mg->mime_signencrypt($email, $in->get('From') =~ /<(.*)>/) and debug 'Could not encrypt message. GnuPG said ', stringify $mg->{last_message};
-       sendmail $email
+       my $encrypt_failed = $mg->mime_signencrypt($email, $in->get('From') =~ /<(.*)>/);
+       debug 'Could not encrypt message, sending unencrypted. GnuPG said ', stringify $mg->{last_message} if $encrypt_failed;
+       sendmail $encrypt_failed ? $email_unencrypted : $email
 }
 
 1;
 }
 
 1;
This page took 0.010548 seconds and 4 git commands to generate.