* Thus wrote Robert Van Overmeiren ([EMAIL PROTECTED]): > Hello, > > I want to take a String variable and GPG encrypt it, then email the > encrypted string. > > One of our developers suggested using "proc_open" and to "set the process to > 'gpg -a --encrypt -r 0x35E891B0'", but couldn't clarify. > > How is this done? Would it be something like this...?
I'm not familiar with proc_open being that it is knew but yes the idea is correct. > ----------------------------------------- > > $message = "Text or HTML string"; > > $pipes = "-a --encrypt -r 0x35E891B0"; The $pipes parameter isn't the arguments to the script but an array that is returned with the pipe you defiend below. > > $descriptorspec = array(0 => array("pipe", "r"), 1 => array("pipe", "w"), 2 > => array("file", "/tmp/error-output.txt", "a")); In most cases you may want your #2 stream (the error stream) to go to a pipe back to this script. so you want 2=> array('pipe', 'r') > > $process = proc_open("gpg", $descriptorspec, $pipes); Pass your parameters like so: $process = proc_open("gpg -a --encrypt ...", $descriptorspec, $pipes); > > if (is_resource($process)) { > fwrite($pipes[0], $message); > fclose($pipes[0]); Now you can check the error stream and do some error checking: while(!feof($pipes[2])) { $errors .= fgets($pipes[2], 1024); } fclose($pipes[2]); //... error checking stuff. > while(!feof($pipes[1])) { > echo fgets($pipes[1], 1024); > } > fclose($pipes[1]); > $return_value = proc_close($process); > } > > send_mail($smtp_server, $smtp_port, $sender_email, $recipient_email, > $subject, $message, $headers); > I believe you need to set some headers to tell the email program that this message is encrypted, but I might be wrong. Curt -- List Stats: http://zirzow.dyndns.org/html/mlists/php_general/ "I used to think I was indecisive, but now I'm not so sure." -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php