EventListener et Symfony Mailer
Bonjour tout le monde,
Je vous présente le petit contrôleur suivant :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| <?php
namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Mailer\MailerInterface;
use Symfony\Component\Mime\Email;
use Symfony\Component\Routing\Annotation\Route;
class MailController extends AbstractController
{
#[Route('/mail', name: 'app_mail')]
public function index(MailerInterface $mailer): Response {
//$mail = $this->get("mailer") ;
$email = (new Email())
->from('****@****')
->to('****@****')
//->cc('cc@example.com')
//->bcc('bcc@example.com')
//->replyTo('fabien@example.com')
//->priority(Email::PRIORITY_HIGH)
->subject('Time for Symfony Mailer!')
->text('Sending emails is fun again!')
->html('<p>See Twig integration for better HTML integration!</p>');
$mailer->send($email);
}
} |
Jusqu'ici, tout fonctionne :D
Mais j'aimerai bien passer du contrôleur à un EventListener et là, Je sèche :(
Une idée?
Merci par avance ;)