src/Controller/HomePageController.php line 21

  1. <?php
  2. namespace App\Controller;
  3. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  4. use Symfony\Component\HttpFoundation\Response;
  5. use Symfony\Component\Routing\Annotation\Route;
  6. use Symfony\Contracts\HttpClient\HttpClientInterface;
  7. use App\Services\PaaeApiRequests;
  8. use App\Services\ImportPaaeService;
  9. use Symfony\Component\Mailer\MailerInterface;
  10. use Symfony\Component\Mime\Email;
  11. class HomePageController extends AbstractController
  12. {
  13.     #[Route('/'name'app_index')]
  14.     public function index(HttpClientInterface $httpClientPaaeApiRequests $requestImportPaaeService $import): Response
  15.     {
  16.         $import->importUserData();
  17.         return $this->render('home_page/index.html.twig', [
  18.             'controller_name' => 'HomePageController'
  19.         ]);
  20.     }
  21.     #[Route('/send-email'name'email_sender')]
  22.     public function email(MailerInterface $mailerHttpClientInterface $httpClientPaaeApiRequests $request): Response
  23.     {
  24.         $email = (new Email())
  25.             ->from('[email protected]')
  26.             ->to('[email protected]')
  27.             ->subject('Email Test')
  28.             ->text('A sample email using mailtrap.');
  29.         $mailer->send($email);
  30.         dd($email);
  31.         return new Response(
  32.             'Email sent successfully'
  33.         );
  34.     }
  35. }