I'm going to run production project but still cannot resolve a problem with sending signed templated email. I've googled and there are a few people with the same problem without clear answer. I believe that problem is related with Event. But don't understand logic and how it should work.
When I try to sign and send I have error: A message must have a text or an HTML part or attachments.
Without signing everything work as excepted but I need email to be signed. Thank you for any help or right direction how to fix this.
# Configuration
framework:
messenger:
transports:
liip_imagine: '%env(MESSENGER_TRANSPORT_DSN)%/symfony/consumer-%env(CONSUMER_ID)%?auto_setup=true&delete_after_ack=true'
async: '%env(MESSENGER_TRANSPORT_DSN)%/symfony/consumer-%env(CONSUMER_ID)%?auto_setup=true&delete_after_ack=true'
sync: 'sync://'
routing:
# Route your messages to the transports
Liip\ImagineBundle\Message\WarmupCache: liip_imagine
Symfony\Component\Mailer\Messenger\SendEmailMessage: async
# Templated email
$email = new TemplatedEmail;
$email->templatedEmail
->from($fromEmail)
->to($toEmail)
->priority(Email::PRIORITY_HIGHEST)
->subject('Subject')
->htmlTemplate('emails/signup_confirm.html.twig')
->context(['item' => $item])
;
# DKIM Signing.
$signer = new DkimSigner($content_from_key, 'domain.com', 'dkim');
// Sign email.
$signedEmail = $signer->sign($email);
# Dispatch email
try {
$mailer->send($signedEmail);
} catch (TransportExceptionInterface $e) {
$logger->critical($e->getMessage());
}