<?php
$data = <<<EOD
You have my authorization to spend $10,000 on dinner expenses.
The CEO
EOD;
$fp = fopen("msg.txt", "w");
fwrite($fp, $data);
fclose($fp);
if (openssl_pkcs7_sign("msg.txt", "signed.txt", "mycert.pem",
array("file://mycert.pem", "mypassphrase"),
array("To" => "joes@example.com", "From: HQ <ceo@example.com>", "Subject" => "Eyes only")
)) {
exec(ini_get("sendmail_path") . " < signed.txt");
}
?>