+if ($entity->parts) {
+ # MIME
+
+ my ($got_sig, $got_text) = (0, 0);
+ my ($sig_name,$sig_fh,$text_name,$text_fh);
+ ($sig_fh, $sig_name) = tempfile();
+ ($text_fh, $text_name) = tempfile();
+
+ foreach my $subent ($entity->parts) {
+ if ($subent->effective_type eq "text/plain") {
+ @COMMANDS = split /\n/,$subent->bodyhandle->as_string;
+
+ my $str = $subent->as_string;
+ $str =~ s/=\n$//;
+ $str =~ s/\n/\r\n/g;
+ print $text_fh $str;
+ close($text_fh);
+ $got_text++;
+ } elsif ($subent->effective_type eq
+ "application/pgp-signature") {
+ print $sig_fh $subent->as_string;
+ close($sig_fh);
+ $got_sig++;
+ }
+ }
+
+ if ($got_sig && $got_text) {
+ my $pid = open3(\*GPGIN, \*GPGOUT, \*GPGERR,
+ "gpg --batch --verify ".
+ $sig_name." ".$text_name);
+
+ close GPGIN;
+
+ @GPGERROR=<GPGERR>;
+ my @GPGOUTPUT=<GPGOUT>;
+ close GPGERR;
+ close GPGOUT;
+ waitpid $pid, 0;
+
+ unlink($text_name);
+ unlink($sig_name);
+ }
+} else {
+ # Clear text.