Вопрос по GPG+PHP

chiffa

Guest
Вопрос по GPG+PHP

Всем привет у меня такой трабл. Есть скрипт отправки письма, но перед отправкой сообщение должно шифроваться. НИже привожу код:

PHP:
<?php

  $from = $HTTP_POST_VARS['from'];
  $title = $HTTP_POST_VARS['title'];
  $body = $HTTP_POST_VARS['body'];

  $to_email = '[email protected]';


  putenv('GNUPGHOME=/.gnupg');

  
  $infile = tempnam('', 'pgp');
  $outfile = $infile.'.asc';

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

  
  $command =  "/usr/bin/gpg -a \\
               --recipient 'login <[email protected]>' \\
               --encrypt -o $outfile $infile";

  
  system($command, $result);

  
  unlink($infile);

  if($result==0)
  {
    $fp = fopen($outfile, 'r');
    if(!$fp||filesize ($outfile)==0)
    {
      $result = -1;
    }
    else
    {
     
      $contents = fread ($fp, filesize ($outfile));
      
      unlink($outfile);

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

  if($result!=0)
  {
    echo '<h1>Error:</h1>
          <p>Your message could not be encrypted, so has not been sent.</p>
          <p>Sorry.</p>';
  }
?>
Вроде как все должно работать, но выдает Your message could not be encrypted, so has not been sent. Может кто подскажет вчем ошибка?! Зарание спасибо!
 
Сверху