If true, then skip the signing step. Default: B<0>.
+=item B<mail-template> [string]
+
+Email template which is used as the body text for the email sent out.
+instead of the default text if specified. The following perl variables
+can be used in the template:
+
+=over
+
+=item B<{owner}> [string]
+
+Your name as specified in the L<B<owner>|/item_owner__5bstring_5d> setting.
+
+=item B<{key}> [string]
+
+The keyid of the key you signed.
+
+=item B<{@uids}> [array]
+
+The UIDs for which signatures are included in the mail.
+
+=back
+
=back
=head1 AUTHOR
use English;
use File::Path;
use File::Temp qw{tempdir};
+use Text::Template;
use MIME::Entity;
use Fcntl;
use IO::Select;
$CONFIG{'secret-keyring'} = $ENV{'HOME'}.'/.gnupg/secring.gpg' unless defined $CONFIG{'secret-keyring'};
$CONFIG{'no-download'} = 0 unless defined $CONFIG{'no-download'};
$CONFIG{'no-sign'} = 0 unless defined $CONFIG{'no-sign'};
+ $CONFIG{'mail-template'} = <<'EOM' unless defined $CONFIG{'mail-template'};
+Hi,
+
+please find attached the user id{(scalar @uids >= 2 ? 's' : '')}.
+{foreach $uid (@uids) {
+ $OUT .= "\t".$uid."\n";
+};} of your key {$key} signed by me.
+
+Note that I did not upload your key to any keyservers. If you want this
+new signature to be available to others, please upload it yourself.
+With GnuPG this can be done using
+ gpg --keyserver subkeys.pgp.net --send-key {$key}
+
+If you have any questions, don't hesitate to ask.
+
+Regards,
+{$owner}
+EOM
};
sub notice($) {
sub send_mail($$$@) {
my ($address, $can_encrypt, $key_id, @keys) = @_;
- my $message = "Hi,\n\n";
+ my $template = Text::Template->new(TYPE => 'STRING', SOURCE => $CONFIG{'mail-template'})
+ or die "Error creating template: $Text::Template::ERROR";
- $message .= 'please find attached the user id'.(scalar @keys >= 2 ? 's' : '')."\n";
+ my @uids;
for my $key (@keys) {
- $message .= "\t".$key->{'text'}."\n";
+ push @uids, $key->{'text'};
};
- $message .= qq{of your key $key_id signed by me.
+ my $message = $template->fill_in(HASH => { key => $key_id,
+ uids => \@uids,
+ owner => $CONFIG{'owner'}})
+ or die "Error filling template in: $Text::Template::ERROR";
-Note that I did not upload your key to any keyservers. If you want this
-new signature to be available to others, please upload it yourself.
-With GnuPG this can be done using
- gpg --keyserver subkeys.pgp.net --send-key $key_id
-
-If you have any questions, don't hesitate to ask.
-
-Regards,
-$CONFIG{'owner'}
-};
my $message_entity = MIME::Entity->build(
Type => "text/plain",
Charset => "utf-8",
next;
};
my @publine = grep { /^pub/ } (split /\n/, $stdout);
+ if (scalar @publine == 0) {
+ warn ("No public keys found with list-key $keyid (note that caff uses its own keyring in $GNUPGHOME).\n");
+ next;
+ };
my (undef, undef, undef, undef, $longkeyid, undef, undef, undef, undef, undef, undef, $flags) = split /:/, pop @publine;
if (scalar @publine > 0) {
warn ("More than one key matched $keyid. Try to specify the long keyid or fingerprint\n");
-d $keydir || mkpath($keydir , 0, 0700) or die ("Cannot create $keydir $!\n");
my $keyfile = "$keydir/$longkeyid.key.$uid_number.".sanitize_uid($this_uid_text).".asc";
- open (KEY, ">$keyfile") or die ("Cannot open $keyfile\n");
+ open (KEY, ">$keyfile") or die ("Cannot open $keyfile: $!\n");
print KEY $asciikey;
close KEY;
my $keydir = "$KEYSBASE/$DATE_STRING";
my $mailfile = "$keydir/$longkeyid.mail.".$uid->{'serial'}.".".sanitize_uid($uid->{'text'});
- open (KEY, ">$mailfile") or die ("Cannot open $mailfile\n");
+ open (KEY, ">$mailfile") or die ("Cannot open $mailfile: $!\n");
print KEY $mail;
close KEY;
};