Symfony 4.3 Mailer – undefined method named "getAll" of class "SymfonyComponentMimeHeaderHeaders"

I’m trying to send mails with the new mailer component in symfony 4.3 but if i try my implemetation, i’m getting this exception:

Attempted to call an undefined method named “getAll” of class “SymfonyComponentMimeHeaderHeaders”.

stack trace:

SymfonyComponentDebugExceptionUndefinedMethodException:
Attempted to call an undefined method named "getAll" of class "SymfonyComponentMimeHeaderHeaders".

  at vendor/symfony/mailer/DelayedSmtpEnvelope.php:76
  at SymfonyComponentMailerDelayedSmtpEnvelope::getRecipientsFromHeaders(object(Headers))
     (vendor/symfony/mailer/DelayedSmtpEnvelope.php:69)
  at SymfonyComponentMailerDelayedSmtpEnvelope->getRecipients()
     (vendor/symfony/mailer/Transport/AbstractTransport.php:75)
  at SymfonyComponentMailerTransportAbstractTransport->send(object(Email), object(DelayedSmtpEnvelope))
     (vendor/symfony/mailer/Transport/Smtp/SmtpTransport.php:115)
  at SymfonyComponentMailerTransportSmtpSmtpTransport->send(object(Email), null)
     (vendor/symfony/mailer/Mailer.php:38)
  at SymfonyComponentMailerMailer->send(object(Email))
     (src/Controller/TicketController.php:209)
  at AppControllerTicketController->sendEmail('[email protected]', '[email protected]', null)
     (src/Controller/TicketController.php:193)
  at AppControllerTicketController->handleRequest(object(Request))
     (src/Controller/TicketController.php:51)
  at AppControllerTicketController->createGeneral(object(Request))
     (vendor/symfony/http-kernel/HttpKernel.php:151)
  at SymfonyComponentHttpKernelHttpKernel->handleRaw(object(Request), 1)
     (vendor/symfony/http-kernel/HttpKernel.php:68)
  at SymfonyComponentHttpKernelHttpKernel->handle(object(Request), 1, true)
     (vendor/symfony/http-kernel/Kernel.php:198)
  at SymfonyComponentHttpKernelKernel->handle(object(Request))
     (index.php/:25)

My Code so far:

use SymfonyComponentMailerExceptionTransportExceptionInterface;
use SymfonyComponentMailerMailerInterface;
use SymfonyComponentMimeEmail;

class TicketController extends AbstractController
    {
        private $mailer;
        public function __construct(MailerInterface $mailer)
        {
            $this->mailer = $mailer;
        }

    [...]

        public function sendEmail($ticketRecipient, $responsibilityRecipient)
        {
            $email = (new Email())
                ->from('[email protected]')
                ->to($ticketRecipient, $responsibilityRecipient)
                ->subject('example subject')
                ->text('example text')
                ->html('<p>todo Twig Integration<p/>');

            try {
                $this->mailer->send($email);
            } catch (TransportExceptionInterface $e) {
            }
        }
    }

Am I missing something?

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

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