Mail::GnuPG(3pm)
β¨ Mail::GnuPG π
okay bestie, so this is Mail::GnuPG, the Perl module that does all your PGP signing and encrypting for email. yes THE Mail::GnuPG, from the User Contributed Perl Documentation collection. she's giving cryptography, she's giving mail processing, she's iconic. π
πΈ SYNOPSIS πΈ
use Mail::GnuPG;
my $mg = new Mail::GnuPG( key => 'ABCDEFGH' );
$ret = $mg->mime_sign( $MIMEObj, 'you@my.dom' );
like... three lines and you're already signing mail. obsessed. π
π¦ DESCRIPTION π¦
bestie. she uses GnuPG::Interface to process or create PGP signed or encrypted email. that's the whole vibe. you feed her MIME objects, she signs and encrypts them, no cap. π₯
π new
creates a shiny new Mail::GnuPG instance. brand new, fresh out the box, main character energy. β¨
Arguments:
Paramhash...
key => gpg key id
keydir => gpg configuration/key directory
passphrase => primary key password
use_agent => use gpg-agent if non-zero
always_trust => always trust a public key
# FIXME: we need more things here, maybe primary key id.
yep that # FIXME is literally in there β they said "we need more things here, maybe primary key id." iconic honesty fr fr. π
π decrypt
decrypts an encrypted message. the unlocking moment. π
Input:
MIME::Entity containing email message to decrypt.
the message can either be in RFC compliant-ish multipart/encrypted format, OR just a single part ascii armored message. either way, she handles it. π
Output:
On Failure:
Exit code of gpg. (0 on success)
On Success: (just encrypted)
(0, undef, undef)
On success: (signed and encrypted)
( 0,
keyid, # ABCDDCBA
emailaddress # Foo Bar <foo@bar.com>
)
where keyid is the key that signed it, and emailaddress is the full name and email address of the primary uid. so cute. π
$self->{last_message} => any errors from gpg
$self->{plaintext} => plaintext output from gpg
$self->{decrypted} => parsed output as MIME::Entity
π get_decrypt_key
determines the decryption key (and the corresponding mail) of a message. lowkey detective work. π΅οΈββοΈ
Input:
MIME::Entity containing email message to analyze.
again: the message can either be in RFC compliant-ish multipart/signed format, or just a single part ascii armored message.
Output:
$key -- decryption key
$mail -- corresponding mail address
π verify
verifies a signed message. the vibe check, essentially. β
Input:
MIME::Entity containing email message to verify.
the message can either be in RFC compliant-ish multipart/signed format, or just a single part ascii armored message.
β οΈ not me about to break a signature β οΈ β MIME-encoded data should be supplied unmodified inside theMIME::Entityinput message, otherwise the signature will be broken. periodt. since MIME-tools version 5.419, you can achieve this with thedecode_bodiesmethod ofMIME::Parser. see theMIME::Parserdocumentation for more info.
Output:
On error:
Exit code of gpg. (0 on success)
On success:
( 0,
keyid, # ABCDDCBA
emailaddress # Foo Bar <foo@bar.com>
)
where keyid is the key that signed it, and emailaddress is the full name and email address of the primary uid. the email/uid is UTF8 encoded, as output by GPG. π
$self->{last_message} => any errors from gpg
π has_public_key
does the keyring have a public key for the specified email address? yes/no bestie, that's it. π
FIXME: document better. talk about caching. maybe put a better
interface in.
literally the original author said "document better" and honestly? relatable. π
π mime_sign
signs an email message. π
Input:
MIME::Entity containing email message to sign
Output:
Exit code of gpg. (0 on success)
$self->{last_message} => any errors from gpg
the provided $entity will be signed. (i.e. it _will_ be modified.) heads up, she edits in place, no copy, no warning, just vibes. π
π clear_sign
clearsigns the body of an email message. βοΈ
Input:
MIME::Entity containing email message to sign.
This entity MUST have a body.
Output:
Exit code of gpg. (0 on success)
$self->{last_message} => any errors from gpg
the provided $entity will be signed. (i.e. it _will_ be modified.) again. in place. she's not shy. π
π ascii_encrypt
encrypts an email message body using ascii armor. π‘οΈ
Input:
MIME::Entity containing email message to encrypt.
This entity MUST have a body.
list of recipients
Output:
Exit code of gpg. (0 on success)
$self->{last_message} => any errors from gpg
the provided $entity will be encrypted. (i.e. it _will_ be modified.) π«Ά
π ascii_signencrypt
encrypts and signs an email message body using ascii armor. both. at once. she does it all. π
Input:
MIME::Entity containing email message to encrypt.
This entity MUST have a body.
list of recipients
Output:
Exit code of gpg. (0 on success)
$self->{last_message} => any errors from gpg
the provided $entity will be encrypted. (i.e. it _will_ be modified.) π
π mime_encrypt
encrypts an email message. π
Input:
MIME::Entity containing email message to encrypt
list of email addresses to sign to
Output:
Exit code of gpg. (0 on success)
$self->{last_message} => any errors from gpg
the provided $entity will be encrypted. (i.e. it _will_ be modified.) π
π mime_signencrypt
signs and encrypts an email message. the deluxe combo meal. π
Input:
MIME::Entity containing email message to sign encrypt
list of email addresses to sign to
Output:
Exit code of gpg. (0 on success)
$self->{last_message} => any errors from gpg
the provided $entity will be encrypted. (i.e. it _will_ be modified.) β¨
π is_signed
best guess as to whether a message is signed or not β by looking at the mime type and message content. she's guessing but she's confident. π
Input:
MIME::Entity containing email message to test
Output:
True or False value
π is_encrypted
best guess as to whether a message is signed or not β by looking at the mime type and message content. (yes bestie, the description says "signed" here too. it's in the original. i don't make the rules. π)
Input:
MIME::Entity containing email message to test
Output:
True or False value
π LICENSE π
Copyright 2003 Best Practical Solutions, LLC
this program is free software; you can redistribute it and/or modify it under the terms of either:
- the GNU General Public License as published by the Free Software Foundation; version 2
http://www.opensource.org/licenses/gpl-license.php - the "Artistic License"
http://www.opensource.org/licenses/artistic-license.php
this program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. see either the GNU General Public License or the Artistic License for more details. no warranty bestie, she said what she said. π
π AUTHOR π
Robert Spier
David Bremner <ddb@cpan.org>
π BUGS/ISSUES/PATCHES π
please send all bugs/issues/patches to
bug-Mail-GnuPG@rt.cpan.org
π SEE ALSO π
perl.GnuPG::Interface,MIME::Entity
and that's the whole page bestie!! π this lil manual came from perl v5.40.1, dated 2025-02-28, and it's the Mail::GnuPG(3pm) page β go forth and sign ur mail, u absolute icon. πβ¨π¦
π¦ where this page comes from
- debian trixie: libmail-gnupg-perl 0.23-5 Β· Artistic-1.0-Perl OR GPL-2.0-only
- ubuntu resolute: libmail-gnupg-perl 0.23-5 Β· Artistic-1.0-Perl OR GPL-2.0-only
- ubuntu stonking: libmail-gnupg-perl 0.23-5 Β· Artistic-1.0-Perl OR GPL-2.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms