PGP Encryption for a PHP generated email
That took some real doing. If you have the option, just use PECL extensions. If you don’t, prepare to sit around and try a bunch of things out.
I found several scripts that claimed to be the solution to this issue, but none of them wanted to work. Finally I pieced together something like this-
$commandline = “gpg –homedir /var/www/vhosts/host/httpdocs/gpgtests/gnupg –keyring /var/www/vhosts/host/httpdocs/gpgtests/gnupg/keyring1 -a –always-trust –batch –no-secmem-warning -e -r ‘Fargo Holiday’ -o $outfile $infile”;
system($commandline, $result);
Which still didn’t seem to work, because the line, cribbed from one of the scripts, to check the result before emailing wasn’t firing. It was looking for a $result of 0, and I was getting 2. Turns out, for this case anyway, 2 works just fine.
Also, PGP is awesome, and I feel bad for having mostly ignored it until now.