+ return first_part ($ent->parts(0)) if $ent->parts;
+ stringify [$ent->bodyhandle->as_lines]
+}
+
+sub import_pubkeys {
+ my ($ent, $mg) = @_;
+ my @keys;
+ if ($ent->mime_type eq 'application/pgp-keys') {
+ $ent = mp(1)->parse_data($ent->stringify);
+ my $gpg = GnuPG::Interface->new;
+ $mg->_set_options($gpg);
+ $gpg->options->quiet(1);
+ my ($input, $status) = (IO::Handle->new, IO::Handle->new);
+ my $pid = $gpg->import_keys(handles => GnuPG::Handles->new(stdin => $input, status => $status));
+ my $read = Mail::GnuPG::_communicate([$status], [$input], {$input => $ent->bodyhandle->as_string});
+ push @keys, map { /IMPORT_OK \d+ (\w+)/ } $read->{$status};
+ waitpid $pid, 0
+ }
+ push @keys, import_pubkeys ($_, $mg) for $ent->parts;
+ @keys