Fabien Potencier
Contributed by Fabien Potencier in #37165

DKIM (DomainKeys Identified Mail) is an email authentication method designed to detect forged sender addresses in emails (email spoofing), a technique often used in phishing and email spam.

DKIM allows the receiver to check that an email claimed to have come from a specific domain was indeed authorized by the owner of that domain. In Symfony 5.2 we've added support for DKIM in the Mailer component to allow you affix a digital signature, linked to a domain name, to each outgoing email messages:

1
2
3
4
5
6
7
8
9
10
use Symfony\Component\Mime\Crypto\DkimSigner;
use Symfony\Component\Mime\Email;

$email = (new Email())
    ->from('hello@example.com')
    // ...
    ->html('...');

$signer = new DkimSigner('file:///path/to/private-key.key', 'example.com', 'sf');
$signedEmail = $signer->sign($email);

Read the DKIM signer docs to learn about all the available configuration options.

Published in #Living on the edge