I am new to PHP and since I got engaged in a PHP project I am now in a real problem . Please help me out since you have worked over such a stuff ( I saw it on some forum). I know I am not known to you but please try to help me on humanatarian grounds, in case you can . My query is as follows:-
I need to send an attachment file with NS-cert extension and the email which is to be sent has to be digitally signed. I have pem format certificate with me. I tried using openssl_pkcs7_sign function but with it I could only send one attachment either the message body with content type Text/plain or the ns-cert file with content type application/octet-stream. But I want to send a digitally signed mail with a message body and an attachment of ns-cert file.
Kindly help me out in case you could do something in this ?
My code goes somethin like this..
$data = <<<EOD
MIME-Version: 1.0
Content-Type: application/octet-stream; name=$filename_attachment
Content-Disposition: attachment; filename=$filename_attachment
Content-Transfer-Encoding: 7bit
<?xml version="1.0"?>
<NSCert>
<CSP>$txtCSP</CSP>
<Container>$txtcontainer</Container>
<Certificate>$pkcs12[1]</Certificate>
</NSCert>
EOD;
// save message to file
$fp = fopen($filename_attachment, "w");
fwrite($fp, $data);
fclose($fp);
// encrypt it
//$cert_path = 'file://'.$_SERVER['DOCUMENT_ROOT'].'/geotrust-cert.pem' ;
if (openssl_pkcs7_sign($filename_attachment, "signed.txt", $ssl_cert_path,
array($ssl_cert_path, $cert_password),
array("To" => $txtusrEmailID, // keyed syntax
"From" => $mail_from, // indexed syntax
"Subject" => "Email Notification and Certificate "),PKCS7_NOVERIFY))
{
// message signed - send it!
exec(ini_get("sendmail_path") . " < signed.txt");
}
If in $data I try putting the message body with content type : text/plain , it distorts the ns-cert file sent to the end user.
Kindly help me out otherwise I would really be in BIG trouble. I would be highly grateful to you in cae you could ake me out of this problem.
Waiting for your reply,
Disturbed,
Rohit