note 124271 added to function.openssl-pkcs7-sign

From: Date: Tue, 08 Oct 2019 00:23:58 +0000
Subject: note 124271 added to function.openssl-pkcs7-sign
Groups: php.notes 
Request: Send a blank email to php-notes+get-212548@lists.php.net to get a copy of this message
If you want to use mail() with headers, then you'll need to alter the signed version before embedding in the body or the headers and boundaries will end up in the message. <?php openssl_pkcs7_sign($basedir . 'email.txt', $basedir . 'signed.txt', 'file://' . $basedir . 'cert.pem', array('file://' . $basedir . 'key.pem', $keypass), array('To' => $smime_to, 'From' => $smime_from, 'Subject' => $smime_subject)); if (preg_match('/To: [^\r\n]+(\r|\n)+(From: [^\r\n]+(\r|\n)+)Subject: [^\r\n]+(\r|\n)+MIME-Version: [^\r\n]+(\r|\n)+(Content-Type: [^\r\n]+)(\r|\n)+/', file_get_contents($basedir . 'signed.txt'), $matches)) { $result = mail($smime_to, $smime_subject, str_replace($matches[0], '', file_get_contents($basedir . 'signed.txt')), $mailheaders . $matches[2] . $matches[6]); } ?> With the signed headers removed ($matches[0]) and the headers updated with From (not part of mail()) and Content-Type ($matches[2] / $matches[6] respectively). ---- Server IP: 208.43.231.9 Probable Submitter: 82.199.157.54 (proxied: 59.167.119.189) ---- Manual Page -- http://php.net/manual/en/function.openssl-pkcs7-sign.php Edit -- https://master.php.net/note/edit/124271 Del: integrated -- https://master.php.net/note/delete/124271/integrated Del: useless -- https://master.php.net/note/delete/124271/useless Del: bad code -- https://master.php.net/note/delete/124271/bad+code Del: spam -- https://master.php.net/note/delete/124271/spam Del: non-english -- https://master.php.net/note/delete/124271/non-english Del: in docs -- https://master.php.net/note/delete/124271/in+docs Del: other reasons-- https://master.php.net/note/delete/124271 Reject -- https://master.php.net/note/reject/124271 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#212548) next »