sub decode { my $entity = shift @_; #Create new Mail GPG obj my $mg = Mail::GPG->new; #Decrypt the email from stdin my ($decrypted_entity, $result) = $mg->decrypt ( entity => $entity, passphrase => $passphrase ); #Get a reference to the decoded message body my $decoded_body_sref = $result->get_gpg_stdout; return $decoded_body_sref; # my $to = 'chris'; # my $from = 'root'; # my $subject = 'Test Email'; #open(MAIL, "|/usr/sbin/sendmail -t"); #print MAIL "To: $to\n"; #print MAIL "From: $from\n"; #print MAIL "Subject: $subject\n\n"; #print MAIL $decoded_body_sref ; #close(MAIL); #print "Email Sent Successfully\n"; }