almax
01-10-2004, 10:26 PM
I haven't found mention of email encryption anywhere on HR. In case anyone's interested, here's how you can do it with PHP:
First, get SSH access to your server, login and run gpg in the home directory. The first time, the .gnupg directory is created with pgp encryption keyrings. Run gpg again to install a public key. I'm assuming you know about using PGP or GnuPGP (gpg). You can get some tips from the man page, and more info on the web.
Be sure to chmod the .gnupg directory to 777 and most of the contents to 666, except possibly the secure keyring, if you're using it. Also chmod 777 your tmp directory.
This PHP fragment will encrypt an email $body and send it. A PGP/GnuPGP decrypter and private key is of course needed on the receiving end.
putenv("HOME=/home/your_home_dir");
$tmpfile = "/home/your_home_dir/tmp/".time().".asc";
$fp = popen("/usr/bin/gpg -ear your_public_key_ID -o $tmpfile", 'w');
fwrite($fp, $body, strlen($body));
pclose($fp);
$fp = fopen($tmpfile, 'r');
$body = fread($fp, filesize($tmpfile));
fclose($fp);
unlink($tmpfile);
mail($recipient_email, $subject, $body, "From: $sender_email", "-f$sender_email");
First, get SSH access to your server, login and run gpg in the home directory. The first time, the .gnupg directory is created with pgp encryption keyrings. Run gpg again to install a public key. I'm assuming you know about using PGP or GnuPGP (gpg). You can get some tips from the man page, and more info on the web.
Be sure to chmod the .gnupg directory to 777 and most of the contents to 666, except possibly the secure keyring, if you're using it. Also chmod 777 your tmp directory.
This PHP fragment will encrypt an email $body and send it. A PGP/GnuPGP decrypter and private key is of course needed on the receiving end.
putenv("HOME=/home/your_home_dir");
$tmpfile = "/home/your_home_dir/tmp/".time().".asc";
$fp = popen("/usr/bin/gpg -ear your_public_key_ID -o $tmpfile", 'w');
fwrite($fp, $body, strlen($body));
pclose($fp);
$fp = fopen($tmpfile, 'r');
$body = fread($fp, filesize($tmpfile));
fclose($fp);
unlink($tmpfile);
mail($recipient_email, $subject, $body, "From: $sender_email", "-f$sender_email");