Search code examples
phpopensslphpmailerpublic-key-encryptionsmime

Can't use PHPMailer to sign with S/MIME, getting "Signing Error: "


I'm using phpmailer to try to send signed emails (S/MIME).

I used this excellent tutorial by John Dalesandro to create a Self-Signed S/MIME Certificate and package it in PKCS12 Format.

I then followed the instructions in PHPMailer S/MIME signing to make cert.crt, cert.key & certchain.pem from my PKCS12 package.

When I sign with the code below I get "Signing Error:" :

$mail->sign(
  '/mypath/cert.crt', 
  '/mypath/cert.key', 
  'mypassword',
  '/mypath/certchain.pem'
);

The emails are sent normally when I don't try to sign the email.

Since there is no explanation at all in my error code, I don't understand what I'm doing wrong.


Solution

  • So I got a S/MIME certificate in PKCS12 from a external certificate authority. I then made a cert.crt, cert.key & certchain.pem as stated above and now it works.