Mail::GnuPG(3pm)

πŸ“¦
version 0.23 Β· 4 versions
, in debian trixie, ubuntu resolute, ubuntu stonking

✨ 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 the MIME::Entity input message, otherwise the signature will be broken. periodt. since MIME-tools version 5.419, you can achieve this with the decode_bodies method of MIME::Parser. see the MIME::Parser documentation 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:

  1. the GNU General Public License as published by the Free Software Foundation; version 2 http://www.opensource.org/licenses/gpl-license.php
  2. 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