help needed

Colm McCarthy cdm2 at student.cs.ucc.ie
Tue Mar 1 18:02:51 CET 2005


Hi i was jsut wondering if anyone could help me out, pretty new to gpg and the 
rest. I have supplied the code that im using which i want to encrypt a message 
and send it to my mail account, i will not encrypt for me and i cant figure 
out why, any help would be greatly appreciated.
Thanks.


<?
  $to_email = "cdm2 at student.cs.ucc.ie";

  putenv("GNUPGHOME=Z:2005/cdm2/public_html/.gnupg");

  //create a unique file name
  $infile = tempnam("", "pgp");
  $outfile = $infile.".asc";

  $fp = fopen($infile, "w");
  fwrite($fp, $body);
  fclose($fp);

  //set up our command

$command =  "usr/bin/gpg -e -r cdm2 at student.cs.ucc.ie --encrypt -o $outfile 
$infile";

  // execute our gpg command
  system($command, $result);

  //delete the unencrypted temp file
  unlink($infile);

if($result==0)
  {
    $fp = fopen($outfile, "r");
    if(!$fp||filesize ($outfile)==0)
    {
      $result = -1;
    }
    else
    {
      //read the encrypted file
      $contents = fread ($fp, filesize ($outfile));
      //delete the encrypted temp file
      unlink($outfile);

      mail($to_email, $title, $contents, "From: $from\n");
      echo "<h1>Message Sent</h1>
            <p>Your message was encrypted and sent.
            <p>Thank you.";
  }
}

if($result!=0)
{
  echo "<h1>Error:</h1>
        <p>Your message could not be encrypted, so has not been sent.
        <p>Sorry.";
  }
?>





More information about the Gnupg-users mailing list