WP PGP Encrypted Emails

Encrypts emails WordPress sends using PGP public keys.

Author:Meitar (profile at wordpress.org)
WordPress version required:4.4
WordPress version tested:5.7.2
Plugin version:0.8.0
Added to WordPress repository:22-01-2016
Last updated:25-05-2021
Warning! This plugin has not been updated in over 2 years. It may no longer be maintained or supported and may have compatibility issues when used with more recent versions of WordPress.
Rating, %:92
Rated by:16
Plugin URI:https://github.com/fabacab/wp-pgp-encrypted-e...
Total downloads:21 273
Active installs:500+
plugin download
Click to start download

WP PGP Encrypted Emails can automatically sign and encrypt any email that WordPress sends to your site’s admin email address or your users’s email addresses. You give it a copy of the recipient’s OpenPGP public key and/or their S/MIME certificate, and it does the rest. You can even automatically generate an OpenPGP signing keypair for your site to use.

Encrypting outgoing emails protects your user’s privacy by ensuring that emails intended for them can be read only by them, and them alone. Moreover, signing those emails helps your users verify that email they receive purporting to be from your site was actually sent by your server, and not some imposter. If you’re a plugin or theme developer, you can encrypt and/or sign arbitrary data using this plugin’s OpenPGP and S/MIME APIs, which are both built with familiar, standard WordPress filter hooks. This enables you to develop highly secure communication and publishing tools fully integrated with your WordPress install. See the README.markdown file for details on cryptographic implementation and API usage.

Donations for this and my other free software plugins make up a chunk of my income. If you continue to enjoy this plugin, please consider making a donation. ???? Thank you for your support!

Plugin features:

  • Processes all email your site generates, automatically and transparently.
  • Configure outbound signing: sign email sent to all recipients, or just savvy ones.
  • Per-user encryption keys and certificates; user manages their own OpenPGP keys and S/MIME certificates.
  • Compatible with thousands (yes, thousands) of third-party contact form plugins.
  • Full interoperability with all standards-compliant OpenPGP and S/MIME implementations.
  • Options to enforce further privacy best practices (e.g., removing Subject lines).
  • Fully multisite compatible, out of the box. No additional configuration for large networks!
  • No binaries to install or configure; everything you need is in the plugin itself.
  • Bells and whistles included! For instance, visitors can encrypt comments on posts so only the author can read them.
  • Built-in, customizable integration with popular third-party plugins, such as WooCommerce.
  • Always FREE. Replaces paid email encryption “upgrades,” and gets rid of yearly subscription fees. (Donations appreciated!)
  • And more, of course. ????

The plugin works transparently for all email your site generates, and will also sign and encrypt outgoing email generated by other plugins (such as contact form plugins) or the built-in WordPress notification emails. All you have to do is add one or more OpenPGP keys or an S/MIME certificate to the Email Encryption screen (WordPress Admin Dashboard → Settings → Email Encryption). Each user can opt to also remove envelope information such as email subject lines, which encryption schemes cannot protect. With this plugin, there’s no longer any need to pay for the “pro” version of your favorite contact form plugin to get the benefit of email privacy.

Each of your site’s users can supply their own, personal OpenPGP public key and/or X.509 S/MIME certificate for their own email address to have WordPress automatically encrypt any email destined for them. (They merely need to update their user profile.) They can choose which encryption method to use. Once set up, all future emails WordPress sends to that user will be encrypted using the standards-based OpenPGP or S/MIME technologies.

The OpenPGP-encrypted emails can be decrypted by any OpenPGP-compatible mail client, such as MacGPG (macOS), GPG4Win (Windows), Enigmail (cross-platform), OpenKeychain (Android), or iPGMail (iPhone/iOS). For more information on reading encrypted emails, generating keys, and other uses for OpenPGP-compatible encryption, consult any (or all!) of the following guides:

The S/MIME-encrypted emails can be decrypted by any S/MIME-compatible mail client. These include Apple’s Mail on macOS and iOS for iPhone and iPad, Microsoft Outlook, Claws Mail for GNU/Linux, and more.

For developers, WP PGP Encrypted Emails provides an easy to use API to both OpenPGP and S/MIME encryption, decryption, and integrity validation operations through the familiar WordPress plugin API so you can use this plugin’s simple filter hooks to build custom OpenPGP- or S/MIME-based encryption functionality into your own plugins and themes.

Security Disclaimer

Security is a process, not a product. Using WP PGP Encrypted Emails does not guarantee that your site’s outgoing messages are invulnerable to every attacker, in every possible scenario, at all times. No single security measure, in isolation, can do that.

Do not rely solely on this plugin for the security or privacy of your webserver. See the Frequently Asked Questions for more security advice and for more information about the rationale for this plugin.
If you like this plugin, please consider making a donation for your use of the plugin or, better yet, contributing directly to my Cyberbusking fund. Your support is appreciated!

Themeing

Theme authors can use the following code snippets to integrate a WordPress theme with this plugin.

  • To link to a site’s OpenPGP signing public key: <?php print admin_url( 'admin-ajax.php?action=download_pgp_signing_public_key' ); ?>

Plugin hooks

This plugin offers additional functionality intended for other plugin developers or theme authors to make use of. This functionality is documented here.

Filters

`wp_user_encryption_method`

Gets the user’s preferred encryption method (either pgp or smime), if they have provided both an OpenPGP public key and an S/MIME certificate.

  • Optional arguments:
    • WP_User $user – The WordPress user object. Defaults to the current user.

`wp_openpgp_user_key`

Gets the user’s saved OpenPGP public key from their WordPress profile data, immediately usable in other openpgp_* filters.

  • Optional arguments:
    • WP_User $user – The WordPress user object. Defaults to the current user.

`openpgp_enarmor`

Gets an ASCII-armored representation of an OpenPGP data structure (like a key, or an encrypted message).

  • Required parameters:
    • string $data – The data to be armored.
  • Optional parameters:
    • string $marker – The marker of the block (the text that follows -----BEGIN). Defaults to MESSAGE, but you should set this to a more appropriate value. If you are armoring a PGP public key, for instance, set this to PGP PUBLIC KEY BLOCK.
    • string[] $headers – An array of strings to apply as headers to the ASCII-armored block, usually used to insert comments or identify the OpenPGP client used. Defaults to array() (no headers).

Example: ASCII-armor a binary public key.

$ascii_key = apply_filters('openpgp_enarmor', $public_key, 'PGP PUBLIC KEY BLOCK');

`openpgp_key`

Gets a binary OpenPGP public key for use in later PGP operations from an ASCII-armored representation of that key.

  • Required parameters:
    • string $key – The ASCII-armored PGP public key block.

Example: Get a key saved as an ASCII string in the WordPress database option my_plugin_pgp_public_key.

$key = apply_filters('openpgp_key', get_option('my_plugin_pgp_public_key'));

`openpgp_sign`

Clearsigns a message using a given private key.

  • Required parameters:
    • string $data – The message data to sign.
    • OpenPGP_SecretKeyPacket $signing_key – The signing key to use, obtained by passing the ASCII-armored private key through the openpgp_key filter.

Example: Sign a short string.

$message = 'This is a message to sign.';
$signing_key = apply_filters('openpgp_key', $ascii_key);
$signed_message = apply_filters('openpgp_sign', $message, $signing_key);
// $signed_message is now a clearsigned message

`openpgp_encrypt`

Encrypts data to one or more PGP public keys or passphrases.

  • Required arguments:
    • string $data – Data to encrypt.
    • array|string $keys – Passphrases or keys to use to encrypt the data.

Example: Encrypt the content of a blog post.

// First, get the PGP public key(s) of the recipient(s)
$ascii_key = '-----BEGIN PGP PUBLIC KEY BLOCK-----
[...snipped for length...]
-----END PGP PUBLIC KEY BLOCK-----';
$encryption_key = apply_filters('openpgp_key', $ascii_key);
$encrypted_post = apply_filters('openpgp_encrypt', $post->post_content, $encryption_key);
// Now you can safely send or display $encrypted_post anywhere you like and only
// those who control the corresponding private key(s) can decrypt it.

`openpgp_sign`

Signs a message (arbitrary data) with the given private key.

Note that if your plugin uses the built-in WordPress core wp_mail() function and this plugin is active, your plugin’s outgoing emails are already automatically signed so you do not need to do anything. This filter is intended for use by plugin developers who want to create custom, trusted communiques between WordPress and some other system.

  • Required arguments:
    • string $data – The data to sign.
  • Optional arguments:
    • OpenPGP_SecretKeyPacket $privatekey – The private key used for signing the message. The default is to use the private key automatically generated during plugin activation. The automatically generated keypair is intended to be a low-trust, single-purpose keypair for your website itself, so you probably do not need or want to use this argument yourself.

Example: Send a signed, encrypted JSON payload to a remote, insecure server.

$comment_data = get_comment(2); // get a WP_Comment object with comment ID 2
// Create JSON payload
$json = array('success' => true, 'action' => 'new_comment', 'data' => $comment_data);
$url = 'http://insecure.example.com/';
$response = wp_safe_remote_post($url, array(
));

`openpgp_sign_and_encrypt`

A convenience filter that applies openpgp_sign and then openpgp_encrypt to the result.

  • Required arguments:
    • string $data – The data to sign and encrypt.
    • string $signing_key – The signing key to use.
    • array|string $recipient_keys_and_passphrases – Public key(s) of the recipient(s), or passphrases to encrypt to.

`wp_openpgp_user_key`

Gets the user’s saved S/MIME public certificate from their WordPress profile data, immediately usable in other smime_* filters.

  • Optional arguments:
    • WP_User $user – The WordPress user object. Defaults to the current user.

`smime_certificate`

Gets a PHP resource handle to an X.509 Certificate.

  • Required arguments:
    • mixed $cert – The certificate, either as a string to a file, or raw PEM-encoded certificate data.

`smime_certificate_pem_encode`

Encodes (“exports”) a given X.509 certificate as PEM format.

  • Required arguments:
    • resource $cert

`smime_encrypt`

Encrypts a message as an S/MIME email given a public certificate.

  • Required arguments:
    • string $message – The message contents to encrypt.
    • string|string[] $headers – The message headers for the encrypted part.
    • resource|array $certificates – The recipient’s certificate, or an array of recipient certificates.

This filter returns an array with two keys, headers and message, wherein the message is encrypted.

Example: send an encrypted email via wp_mail(). (You do not need to do this if the recipient is registered as your site’s user, because this plugin does that automatically. Only do this if you need to send S/MIME encrypted email to an address not stored in WordPress’s own database.)

$cert = apply_filters( 'smime_certificate', get_option( 'my_plugin_smime_certificate' ) );
$body = 'This is a test email message body.';
$head = array(
    'From' => get_option( 'admin_email' ),
);
$smime_data = apply_filters( 'smime_encrypt', $body, $head, $cert );
if ( $smime_data ) {
    wp_mail(
        'recipient@example.com',
        'Test message.',
        $smime_data['message'], // message is sent encrypted
        $smime_data['headers']
    );
}

Screenshots
FAQ
ChangeLog