There Are Two Ways For Encrypting Outgoing Emails With GPG/PGP on WordPress. Either Fully Server Side Or PHP5 Based Way Using WP Plugins. Encrypting Outgoing Emails With GPG/PGP on WordPress is often asked topic and the person who is administering or creating the setup must ensure to have complete knowledge (and assumed to have basic knowledge about unix commands) on the topics we are talking about. Encrypting outgoing emails with GPG/PGP on WordPress is possible only in PaaS, Cloud Computing IaaS/Cloud Server, traditional VPS and dedicated servers. Encrypting outgoing emails With GPG/PGP on shared hosting can either fail or can be synonymous with running nude in the public road assuming wearing an invisible bullet proof dress.
Encrypting Outgoing Emails With GPG/PGP on WordPress : Basics Must Be Known
- UNIX Commands
- Determine which method is suitable yourself
- Use a Third Party Mail Server for proper SPF. Read this article.
- We can use Transactional Email services, we gave example on how to send emails from WordPress using Mandrill.
- A computing power is needed for encryption.
- Learn about GNU PG.
Encrypting Outgoing Emails With GPG/PGP on WordPress From Server Side
In this case, we are installing GNU Privacy Guard on server. These should be our steps on SSH for a deb based GNU/Linux like Debian :
1 2 3 4 5 6 7 8 9 10 11 12 | apt-get install gnupg # we can import our signed key sent to key server gpg --keyserver pgp.mit.edu --search-keys me@myemail.tld gpg --import name_of_public_key_file # we can generate key sent on server gpg --gen-key # we can sign gpg --sign-key me@myemail.tld # we can import private key gpg --allow-secret-key-import --import /path/to/key # we commonly sign using this format of command pgp --sign-key "xyzzzd" --signer "######" --sig-type exportable --passphrase "######@##" |
This is not the way when you want only WordPress to handle the emails. Setup can vary and usage of the way should be appropriate.
---
Encrypting Outgoing Emails With GPG/PGP on WordPress Using PHP-GPG
PHP-GPG is a PHP based implementation of GPG.
1 | https://github.com/jasonhinkle/php-gpg |
We need to install this :
1 | apt-get install php5-gnupg |
Then filer the emails with either theme/child theme’s function.php file or our function.php file replacement plugin :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | // This snippet is written by Marcus Povey // Ask question if you have // https://www.marcus-povey.co.uk/2015/06/04/extending-wordpress-to-send-pgp-emails/ // you can copy below this line for personal usage // ask the original creator for pure commercial usage function find_encryption_key($keys) { $fingerprint = null; foreach ($keys as $k) { if ((!$k['expired']) && ($k['can_encrypt']) && (!$fingerprint) && (isset($k['fingerprint']))) { $fingerprint = $k['fingerprint']; } if (!$fingerprint && isset($k['subkeys'])) { $fingerprint = find_encryption_key($k['subkeys']); } } return $fingerprint; } function encryptto($message, $address) { $gpg = new gnupg(); if (is_array($address)) { $address = $address[0]; } $keys = $gpg->keyinfo($address); if ($keys) { $fingerprint = find_encryption_key($keys); $gpg->addencryptkey($fingerprint); return $gpg->encrypt($message); } return false; } add_filter( 'wp_mail', function ($args) { $new_wp_mail = array( 'to' => $args['to'], 'subject' => $args['subject'], 'message' => $args['message'], 'headers' => $args['headers'], 'attachments' => $args['attachments'], ); if ($encrypt = encryptto($args['message'], $args['to'])) { $new_wp_mail['message'] = $encrypt; } return $new_wp_mail; }, 1); |
There are lot of WordPress Plugins to avoid the Server side steps. There are lot plugins available to encrypt the contact us form.
Tagged With exim encrypt outgoing email with pgp gpg , GnuPG wordpress , NB! Outgoing email servers require prior authorization with your e-mail addr , two ways to encrypt outgoing emails