Creating S / MIME from MIME?

I do not quite understand, and some documents or help will be greatly appreciated :)

Using PHP, I create MIME using ezcomponents Mail. But I do not understand:

Do you create an S / MIME message from the original MIME by signing it with openssl_pkcs7_sign ? or do you create S / MIME from scratch and sign it when it's done?

Please carry me when I try to figure out the right way to do things.

EDIT : found this piece of code to better understand my question

<?
// Setup mail headers.
$headers = array("To" => "someone@nowhere.net",
     "From" => "noone@somewhere.net",
     "Subject" => "A signed and encrypted message.");

// Sign the message first
openssl_pkcs7_sign("msg.txt","signed.txt",
     "signing_cert.pem",array("private_key.pem",
     "password"),array());

// Get the public key certificate.
$pubkey = file_get_contents("cert.pem");

//encrypt the message, now put in the headers.
openssl_pkcs7_encrypt("signed.txt", "enc.txt",
     $pubkey,$headers,0,1);

$data = file_get_contents("enc.txt");

// separate header and body, to use with mail function
//  unfortunate but required, else we have two sets of headers
//  and the email client doesn't decode the attachment
$parts = explode("\n\n", $data, 2);

// send mail (headers in the Headers parameter will override those
//  generated for the To & Subject parameters)
mail($mail, $subject, $parts[1], $parts[0]);
?>
+3
source share
1 answer

, , MTA, , . Gnu Anubis ( SMTP) milter

+2

All Articles