I’m trying to send a secure EDI email to the ABF via SMTP using PHP. The content must be encrypted and signed using S/MIME (PKCS#7).
Here’s what ABF requires:
The MIME headers of the attachment must be:
MIME-Version: 1.0
Content-Disposition: attachment; filename=”smime.p7m”
Content-Type: application/x-pkcs7-mime; smime-type=enveloped-data; name=”smime.p7m”
Content-Transfer-Encoding: base64
However, when the recipient downloads the attachment, the file should be named something like:
AA*****_202504021256.edi
How can I send an encrypted S/MIME email where:
MIME headers show the filename as smime.p7m, as required by the recipient
But the downloaded attachment is named like AA*****_202504021256.edi?
I use openssl_pkcs7_sign() and openssl_pkcs7_encrypt() in PHP to generate the .p7m file
$mail->addAttachment(‘ AA*****_202504021256.edi’, ‘smime.p7m’, ‘base64’, ‘application/x-pkcs7-mime; smime-type=enveloped-data’);