Autor Zpráva
norickx
Profil *
Zdravím potřeboval bych pomoci s digitálně podepsaným emailem pomocí phpmailer:

Mail se odešle, ale obsah certifikátu se vloží do těla mailu místo hlavičky (odzkoušeno několik metod, či vydavatelů certifikátů)

Mail body vypadá takto:

bKaJ3t6AMMkSvaAeoMhMtecaVb0UAmf3zoscABzBv0EDJ9osA4VUueVBQUYbd4kc
AqZpSKIu1zsPfZrdBmJQVbq66kO2kIa+P7L1FNgW9051peGn8hUg8JP1yUrCKik5
m9EQXXRy3iIZGepAEczpbmC6zGmVeBiXQUfl/afNq0bZZLD9qvb86NHj0Z3EpsGI
C7giH4/9eTpl

------48BCC340606C04C2614FB9EA56D26481--


kód:

if (!function_exists('file_put_contents')) {
    function file_put_contents($filename, $data) {
        $f = @fopen($filename, 'w');
        if (!$f) {
            return false;
        } else {
            $bytes = fwrite($f, $data);
            fclose($f);
            return $bytes;
        }
    }
}

require 'class.phpmailer.php';
$mail = new PHPMailer();
$dn = array(
    'countryName' => 'CZ',
    'stateOrProvinceName' => 'xxx',
    'localityName' => 'xxx',
    'organizationName' => 'xxxx',
    'organizationalUnitName' => 'xxxx',
    'commonName' => 'PHPMailer Test',
    'emailAddress' => 'xxxx@xxxx.cz'
);
$password = '';
$certfile = 'test_ica.pem';
$keyfile = 'test_ica_s.key';

$pk = openssl_pkey_new();
$csr = openssl_csr_new($dn, $pk);
$cert = openssl_csr_sign($csr, null, $pk, 1);
openssl_x509_export($cert, $certout);
file_put_contents($certfile, $certout);
openssl_pkey_export($pk, $pkeyout, $password);
file_put_contents($keyfile, $pkeyout);

$mail->FromName = "xxxx";
$mail->From = "xxxxx@xxxx.cz";
$mail->AddAddress('xxxx@xxxxx.cz');
$mail->Subject = "PHPMailer Test";
$mail->Sign($certfile, $keyfile, $password);
$body = 'signed email';
$mail->MsgHTML($body);
$mail->IsSMTP();
$mail->Host = 'out.smtp.cz';
//$mail->Port = 2500;
$mail->Send();



PHP Version 4.4.9 OpenSSL/0.9.8

Vaše odpověď

Mohlo by se hodit


Prosím používejte diakritiku a interpunkci.

Ochrana proti spamu. Napište prosím číslo dvě-sta čtyřicet-sedm:

0