hey guys,
Heres the code I’ll explain the problem below
$gpg = '/usr/bin/gpg'; # path to gpg - yours may differ
$recipient = '[email protected]';
$order = ......; # make a composite of your order information
$tmpfile = '/home/username/tmp/phpbasket_' . md5(uniqid(time())); # temp file to encrypt to
$cmd = "$gpg --homedir /home/username/.gnupg --no-default-keyring
--always-trust --no-secmem-warning -e -a --batch -t -r $recipient -o $tmpfile";
$fp = popen($cmd, 'w'); # open a new process to gpg
fwrite($fp, $nospaces); # write the command to encrypt our order to the gpg process
pclose($fp); # close it
$fp = fopen($tmpfile, 'r'); # open the temp file
$enc_order = fread($fp, filesize($tmpfile)); # read the encrypted contents
fclose($fp); # close it
unlink($tmpfile); # delete the temp file
mail($recipient, 'New order!', $enc_order); # mail it to your account
Okay, what I don’t understand is this: $tmpfile = ‘/home/username/tmp/phpbasket_’ . md5(uniqid(time())); # temp file to encrypt to
Explanation:
I’m trying to send encrypted emails that will eventually contain credit card numbers to a client. I found this script at http://www.tiraen.com/dave/php_gpg_howto.html and it says that by using GPG you can send encrypted emails to someone which can then be decrypted using a private key. Now, the script works great (meaning it executes and i get an email) but the email is blank when it should actually be a bunch of encrypted text. my theory is that it has something to do with that temp file. Maybe it’s just not being created. But when i look at the line i don’t understand what file is going to be encrypted exactly. Any ideas on how to get this thing up and running? thanx.