3
有沒有辦法通過pear Mail發送數字簽名電子郵件?如何使用Pear郵件發送數字簽名電子郵件
我看了這段代碼,但沒有運行。
<?php
require_once("Mail.php");
require_once('Mail\mime.php');
$recipients = "[email protected]";
$headers["From"] = "[email protected]";
$headers["To"] = $recipients;
$headers["Subject"] = "Zkouska";
$params["host"] = "mail.xxx.cz";
$params["username"] = "[email protected]";
$params["password"] = "xxx";
$body = "Zkouska Spojeni !";
$mime = new Mail_mime();
$fp = fopen("./msg.txt", "w");
fwrite($fp, $body);
fclose($fp);
echo "Sending mail:\n";
echo "Headers:\n" . print_r($headers);
echo "\n\nBody:\n$body";
echo "\n---END OF MAIL BODY---\n";
openssl_pkcs7_sign("C:/data/www/msg.txt", "C:/data/www/signed.txt", "file://C:/data/www/04.pem", "file://C:/data/www/newkey.pem", $headers);
$data = file_get_contents("C:/data/www/signed.txt");
$mime->setTXTBody($data);
$body = $mime->get();
$headers = $mime->headers($headers);
$headers["Content-Type"] = "Multipart/signed; protocol=\"application/pkcs7-signature\"; micalg=sha1; boundary=\"------------ms070206070302000302000502\"";
$mail_object =& Mail::factory("smtp", $params);
$mail_object->send($recipients, $headers, $body);
echo "Email sent";
?>
有人可以給我建議如何解決這個問題?謝謝。
** 我在互聯網上找到了解決方案,在這裏人們可以使用openssl_pkcs7_sign函數在文件中生成帶簽名的電子郵件。我已經生成這個文件,但我不知道如何解析這個文件$ mail_object->發送函數參數。 Expecially我不知道如何構建頭陣列
文件內容:
MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
From: [email protected]
To: [email protected], [email protected]
Subject: Zkouska
MIME-Version: 1.0
Content-Type: multipart/signed; protocol="application/x-pkcs7-signature"; micalg="sha1"; boundary="----E3E6271C75DBBBCB30B457C24A97B23B"
This is an S/MIME signed message
------E3E6271C75DBBBCB30B457C24A97B23B
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
From: [email protected]
To: [email protected], [email protected]
Subject: Zkouska
#Zkusebni podepsanej email, neodpovidejte prosim
------E3E6271C75DBBBCB30B457C24A97B23B
Content-Type: application/x-pkcs7-signature; name="smime.p7s"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="smime.p7s"
MIIE9wYJKoZIhvcNAQcCoIIE6DCCBOQCAQExCzAJBgUrDgMCGgUAMAsGCSqGSIb3
DQEHAaCCApswggKXMIICAAIBBDANBgkqhkiG9w0BAQQFADCBnDELMAkGA1UEBhMC
Q1oxFzAVBgNVBAgMDkN6ZWNoIFJlcHVibGljMQ8wDQYDVQQHDAZQcmFndWUxDzAN
BgNVBAoMBkRhbnRlbTERMA8GA1UECwwIRW1wbG95ZWUxFzAVBgNVBAMMDkRhbnRl
bSBDQSBhdXRoMSYwJAYJKoZIhvcNAQkBFhdwZXRyLmtvc3Ryb3VuQGRhbnRlbS5j
ejAeFw0xMTA5MDgxMDQyNDJaFw0yMTA3MTcxMDQyNDJaMIGKMQswCQYDVQQGEwJD
WjEXMBUGA1UECBMOQ3plY2ggUmVwdWJsaWMxDzANBgNVBAoTBkRhbnRlbTERMA8G
A1UECxMIRW1wbG95ZWUxFjAUBgNVBAMTDVBldHIgS29zdHJvdW4xJjAkBgkqhkiG
9w0BCQEWF3BldHIua29zdHJvdW5AZGFudGVtLmN6MIGfMA0GCSqGSIb3DQEBAQUA
A4GNADCBiQKBgQCwxNLJPu46NOuGVuQSNtoOUZjN6QYoxSgpOhFtn6Ld/5MaJAaX
SLg3jm2F7NKXvazdma0MZnWiKoomekx77bHSHqSriq5PrO0FxR2V81jGpVKd2jS2
XoMEgiz2bGuy6xWIrdl/ocmMvrusRbL1N/prJGcQCI7TvLlWZr3+otauZwIDAQAB
MA0GCSqGSIb3DQEBBAUAA4GBAJS0U/u8RHlzxVId86lXF1IHdJlmUfqM5uJ0zrjE
a6g1C/7pExSpM9s7RqDkDdgHk2Ok3bl2XBmDvWNWJSsNxc9Gy77gT4qwm93og03p
FDn3ikBIhP+LddDwvre28/eVu/59R6QGMe2VEGNREWvdPHbV7KD1GPim9AL4il3j
VMtHMYICJDCCAiACAQEwgaIwgZwxCzAJBgNVBAYTAkNaMRcwFQYDVQQIDA5DemVj
aCBSZXB1YmxpYzEPMA0GA1UEBwwGUHJhZ3VlMQ8wDQYDVQQKDAZEYW50ZW0xETAP
BgNVBAsMCEVtcGxveWVlMRcwFQYDVQQDDA5EYW50ZW0gQ0EgYXV0aDEmMCQGCSqG
SIb3DQEJARYXcGV0ci5rb3N0cm91bkBkYW50ZW0uY3oCAQQwCQYFKw4DAhoFAKCB
2DAYBgkqhkiG9w0BCQMxCwYJKoZIhvcNAQcBMBwGCSqGSIb3DQEJBTEPFw0xMTA5
MDgxNjE5MzJaMCMGCSqGSIb3DQEJBDEWBBTW5eHrz1I9fM/YTcek/1RBvTrPqzB5
BgkqhkiG9w0BCQ8xbDBqMAsGCWCGSAFlAwQBKjALBglghkgBZQMEARYwCwYJYIZI
AWUDBAECMAoGCCqGSIb3DQMHMA4GCCqGSIb3DQMCAgIAgDANBggqhkiG9w0DAgIB
QDAHBgUrDgMCBzANBggqhkiG9w0DAgIBKDANBgkqhkiG9w0BAQEFAASBgIUpL8bB
w4UpFJEdUO2f0aIc0nm7XnEtVUPkBhhfAfikSJLjNraLmlwQq0f7R/EHdeUzutvW
nuY8A5NtqNF/Efyy8g19GEXCDgxYMgSiUn8AEhhdUvs7Qe45B3ONgLdYfmnF8yX/
w/ZrUGzcmG46dsH/HPapYFmscmbbm5G1GWdU
------E3E6271C75DBBBCB30B457C24A97B23B--
感謝您的幫助
有你發佈的代碼兩次的理由。這是你試圖運行的嗎? –
當然不是,重複的代碼已被修復。 –
傾聽PEAR的使用! – powtac