Home > Software design >  Send email with Symfony 5.3 from the console
Send email with Symfony 5.3 from the console

Time:06-07

I'm creating a command to send email from the console with Symfony 5.3 but the email is not sent and no errors. In my website I have pages where I send emails and everything works fine. This is my execute function from the command:

 protected function execute(InputInterface $input, OutputInterface $output): int
     {
         $io = new SymfonyStyle($input, $output);
         $email = (new Email())
             ->from('*****')
             ->to('*****')
             ->subject('test')
             ->html('test');

         $this->mailer->send($email);

         $io->success('Export terminé');
         return 0;
     }
 

CodePudding user response:

I found the solution: I was using the

Symfony\Component\Mailer\MailerInterface

class for the mailer and it worked with the

Symfony\Component\Mailer\Transport\TransportInterface

class

  • Related