From 70f9c37db1acb0579cf25d611468ddbb338c2efa Mon Sep 17 00:00:00 2001 From: Marius Gavrilescu Date: Mon, 7 Jul 2014 12:23:36 +0300 Subject: [PATCH] Send unencrypted replies if encryption fails --- lib/App/EdwardNG.pm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/App/EdwardNG.pm b/lib/App/EdwardNG.pm index 256cf7d..08b50eb 100644 --- a/lib/App/EdwardNG.pm +++ b/lib/App/EdwardNG.pm @@ -129,9 +129,11 @@ sub run { Subject => 'Re: ' . $in->get('Subject'), Data => $data); + my $email_unencrypted = $email->dup; 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; -- 2.39.2