I'm trying to encrypt an e-mail web form using PGP. One of my problems is that my unix virtual server does not allow SSH or Telnet access so I am forced to upload my public key via ftp to the directory /temp, and call on the key from there. The popular script below does not work as I continually receive Error # 5 messages. This is probably due to the fact that it can't find the public key to encrypt with. Any suggestions?
//build the message string
$msg = "Sender's Full Name:\t$sender_name\n";
$msg .= "Sender's E-Mail:\t$sender_email\n";
$msg .= "Secret Message:\t$secret_msg\n\n";
//set the environment variable for PGPPATH
putenv("PGPPATH=/$DOCUMENT_ROOT/mydomain/temp/");
$p = $PGPPATH;
//generate token for unique filenames
$tmpToken = md5(uniqid(rand()));
//create vars to hold paths and filenames
$plainTxt = "/$DOCUMENT_ROOT/mydomain/temp/" . "$tmpToken" . "data";
$crypted = "/$DOCUMENT_ROOT/mydomain/temp/" . "$tmpToken" . "pgpdata";
//open file and dump in plaintext contents
$fp = fopen($plainTxt, "w+");
fputs($fp, $msg);
fclose($fp);
$pgp_id = "mydomain<info@mydomain.com>";
//invoke PGP to encrypt file contents
system("/usr/local/bin/pgp -e \"$pgp_id\" -o $crypted -a $plainTxt");
//open file and read encrypted contents into var
$fd = fopen($crypted, "r");
$mail_cont = fread($fd, filesize($crypted));
fclose($fd);
// Build mail message and send it to target recipient.
$recipient = "syndicate@ncweb.com";
$subject = "Secret Message";
$mailheaders = "From: info@mydomain.com\n";
$mailheaders .= "Reply-To: $sender_email\n\n";
mail("$recipient", "$subject", $mail_cont, $mailheaders);
// Print confirmation to screen.
echo "<H1 align=center>Thank You, $sender_name</h1>
<p align=center>Your secret message has been sent.</p>";