Symfony 5.2 DkimSigner not working (DKIM lookup KO)

I never ask questions here usually but I’m stuck right now.

I’ve just upgraded my Symfony projet from 5.0 to 5.2 because I needed to DKIM sign my emails and there is a new feature to sign emails with Symfony Mailer on 5.2 : https://symfony.com/blog/new-in-symfony-5-2-dkim-email-authentication

I can’t find any support on this so I hope someone had the same problem as me.

I basically followed documentation by implementing my signature on my mail like that :

$email = (new TemplatedEmail())
         ->from(new Address('[email protected]', 'Noreply'))
         ->to($userEmail)
         ->subject('Subject')
         ->text('My email text format')
         ->htmlTemplate('email.html.twig')
         ->context([
            ...
         ]);

$signer = new DkimSigner(
            'file://dirname(__DIR__).'/../'.$this->getParameter('private_key_filename')',
            $this->getParameter('domain_name'),
            $this->getParameter('selector')
        );
$signedEmail = $signer->sign($email);

$mailer->send($signedEmail);

I also tried getting content :

$signer = new DkimSigner(
                file_get_contents(dirname(__DIR__).'/../'.$this->getParameter('private_key_filename')),
                $this->getParameter('domain_name'),
                $this->getParameter('selector')
            );

I still have "body has been altered" when using multiple DKIM lookup and the test fail.

I don’t think there is a problem in charging the private key file because I first had those kind of errors that I fixed by adding the "/../" on the path.

I’ve set the public key on my DNS with TXT record and domain selector._domainkey.domain.com like that :

v=DKIM1;k=rsa;p=mypublickey

I don’t think this is a problem of key integrity because I used openssl to generate the private and public keys :

openssl genrsa -out private.key 1024
openssl rsa -in private.key -pubout -out public.key

And I can’t sign my email by using my SMTP server because I’m having a mutualized offer and I can’t change server configurations.

Thank you for your time and I hope someone had the same problem !

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *