Clients::Camelot::Mail use Mail::Send; use PGP5::Pipe; use PGP5::Keyring; use User::Log; use File::Basename; use MIME::QuotedPrint (); ############################################# sub _mail { my($send, $subject, $body, $to, @cc)=@_; $send->subject($subject); $send->to($to); $send->set('Cc', @cc) if @cc; ## Send the message my $fh=$send->open('sendmail'); $fh->print($body); $fh->close; return; } _start $kernel->sig('USR1', 'reload'); $kernel->yield('reload'); # make sure keys are loaded mail my $send=Mail::Send->new(); $send->set('MIME-Version', '1.0'); $send->set('Content-Type', 'text/plain; charset="iso-8859-1"'); $send->set('Content-Transfer-Encoding', 'quoted-printable'); _mail($send, $subject, scalar MIME::QuotedPrint::encode_qp($text), @to); ::mylog("Mailing '$subject' to '", join("', '", @to), "'"); pgp5mail my $crypt; my(@keys, @err, $key); eval { foreach my $dest (@to) { $key=$heap->{keyring}->Find(Desc=>$dest); if($key) { push @keys, $key; } else { push @err, "Error: Unable to find PGP5 key for '$dest'"; } } $text=~s/\r//g; $text=~s/\n/\r\n/g; ::mylog("Encrypted to ", join ', ', map {$_->{Keyid}} @keys); $crypt=$heap->{pgp}->Encrypt(Text=>$text, Armor=>1, Key=>\@keys, # Ascii=>1, ); }; push @err, "Error: $@" if $@; ::mylog(join "\n", @err) if(@err); $crypt=join "\n", ('-' x 40), @err, ('-' x 40), '', $crypt if @err; my $send=Mail::Send->new(); _mail($send, $subject, $crypt, @to); ::mylog("PGP5 Mailing '$subject' to '", join("', '", @to), "'"); reload $heap->{pgp}=new PGP5::Pipe; die "Unable to create PGP5::Pipe\n" unless ref $heap->{pgp}; $heap->{keyring}=new PGP5::Keyring $heap->{pgp}; die "Unable to create PGP5::Keyring\n" unless ref $heap->{keyring}; ::mylog("Loaded the following keys: \n", join '', map {$_->as_string} $heap->{keyring}->List_Keys);