0

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());
}
Pavel
  • 1
  • 1
  • In my opinion, the plain text is missing in the email. The HTML part is an attachment. An email without PlainText is not a qualified email according to the standard and is therefore also classified as spam by SpamFilter. Therefore, set the PlainText part with `textTemplate()` and try again. – Hans FooBar Jun 10 '23 at 15:07
  • Thx. But that doesn't help. I did some tests with disabled async in messenger and sending TemplatedEmail work flawlessly. – Pavel Jun 11 '23 at 13:07

0 Answers0