From 741752dc7ef36c94ecbbdc006b2c45d0269f74f7 Mon Sep 17 00:00:00 2001 From: Andrew Ruthven Date: Fri, 7 Mar 2014 23:22:23 +1300 Subject: [PATCH] Get Encrypt + Sign working. --- merge.pl | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/merge.pl b/merge.pl index dc11004..cb135ce 100755 --- a/merge.pl +++ b/merge.pl @@ -187,24 +187,33 @@ while (my $cols = $csv->getline_hr($IN) ) { if defined $tmplData->{$extra}; } - # Possibly GPG Encrypt the message. - if ($tmplData->{'encrypt'}) { - my $ret = $mg->mime_encrypt($mail, @emails); + # Possibly GPG Encrypt and Sign the message. + if ($tmplData->{'encrypt'} && $tmplData->{'sign'}) { + my $ret = $mg->mime_signencrypt($mail, @emails); if ($ret != 0) { warn "Sorry, gpg encrypt error: " . join(", ", @{ $mg->{last_message} }) . "\n"; push @gpg_failed_addresses, @emails; next; } - } # Possibly GPG Sign the message. - if ($tmplData->{'sign'}) { + } elsif ($tmplData->{'sign'}) { my $ret = $mg->mime_sign($mail, $tmplData->{'from'}); if ($ret != 0) { die "Sorry, gpg sign error: " . join(", ", @{ $mg->{last_message} }) . "\n"; } + + # Possibly GPG Encrypt the message. + } elsif ($tmplData->{'encrypt'}) { + my $ret = $mg->mime_encrypt($mail, @emails); + + if ($ret != 0) { + warn "Sorry, gpg encrypt error: " . join(", ", @{ $mg->{last_message} }) . "\n"; + push @gpg_failed_addresses, @emails; + next; + } } $mail->send('sendmail'); -- 2.30.2