]> git.etc.gen.nz Git - mail-merge.git/commitdiff
Get Encrypt + Sign working.
authorAndrew Ruthven <puck@catalyst.net.nz>
Fri, 7 Mar 2014 10:22:23 +0000 (23:22 +1300)
committerAndrew Ruthven <puck@catalyst.net.nz>
Fri, 7 Mar 2014 10:22:23 +0000 (23:22 +1300)
merge.pl

index dc11004539791a7c5b55e53108328d9f34bc7965..cb135ce8102c0496f1044a4fa416a8ec3a87e4ef 100755 (executable)
--- 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');