OK, I've been banging my head against the wall for a few hours on this one ...
I'm trying to take some form values, encrypt them, and email them off to someone. I developed this code on OS X. I've also tested the code, and it works fine on my Linux server. However, it refuses to cooperate on my Win2K server (which is what it needs to run on).
I know that GPG isn't firing correctly because the script complains that it can't open the encrypted file that GPG should be creating. I'm fairly certain that GPG is actually executing, as I'm not getting any error messages that seem to pertain to my system() call (earlier I had to change perms on CMD.EXE to get rid of a pesky problem that was preventing anything from happening).
// Generate a random filename for the plain text and encrypted files
$token = md5(uniqid(rand()));
$text = $token . ".dat";
$enc = $token . ".enc";
// Open the plain text file, and dump the unecrypted mail contents to it
$ftext = fopen($text, "w+");
fputs($ftext, $mailbody);
fclose($ftext);
// Figure out how we're going to call GPG and then encrypt the plain text file
$gpg = $GPG_PATH . " --encrypt -ao " . $enc . " -r \"" . $RECIPIENT . "\" " .
"--default-key \"Sender <forms@host.com>\" --always-trust " . $text;
system($gpg);
// Open the encrypted file and read its contents
$fenc = fopen($enc, "r");
$encrypted = fread($fenc, filesize($enc));
fclose($fenc);
$GPG_PATH and $RECIPIENT are set earlier in the script. I know that they are set correctly. I know the the keys all exist on the Win2K server. I've had the script dump the contents of $gpg to the browser, then pasted that over and run it from CMD.EXE on the Windows server, and it works just fine. So, I KNOW that the way the script is creating the $gpg var is correct.
If you don't have any insight into this problem, do you have any ideas on what I can do to find out what's going wrong? I'd really like to dump the error message that I'm assuming GPG is throwing out so I can see that, but the best I've been able to do is get exec to give me a "2".
TIA,
Jeremy