Web Hosting Talk







View Full Version : GPG question


WebBloom
02-25-2002, 01:27 PM
I have recently setup GPG on my server and wrote a PHP script which encrypts some data using GPG and then emails me the results.

The problem is that the body of the email I receive is blank.

Could this be a permission problem and do I need to setup cgiwrap for use with PHP? Any suggestions would be greatly appreciated.

Following is the code that I use to do this:

//Set variables

//Directory containing the key ring
$gnupghome = "/var/www/vhosts/domainname.com/.gpg";
$gpg = "/usr/local/bin/gpg";
$recipient = "John Doe <jdoe@mail.com>";
$to = "jdoe@mail.com";
$subject = "Test";
$message = "This is a test";

//Set the environment variable for GNUPGHOME
putenv("GNUPGHOME=$gnupghome");

$command = "$gpg --armor -t --always-trust --batch --no-tty
";
$command .= "--compress-algo 1 --cipher-algo cast5 ";
$command .= "--recipient '$recipient' ";
$command .= "--encrypt ";
$command .= "| /bin/mail -s '$subject' $to";
$pp = popen($command, "w");
fputs($pp, $message);
pclose($pp);



Thanks,

David Delisle

priyadi
02-26-2002, 08:10 AM
If there was an error in GPG, it will be reported in your error log file. If you don't have access to your log file, redirect stderr to stdout, so error message will be displayed on your browser.

To do that, change the line:
$command .= "| /bin/mail -s '$subject' $to";

To:
$command .= "| /bin/mail -s '$subject' $to 2>&1";