Licitator 1.0
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55 lines
1.6 KiB

5 years ago
  1. <?php
  2. namespace Zitec\RuleEngineBundle\Command;
  3. use Twig\Environment;
  4. use Doctrine\ORM\EntityManagerInterface;
  5. use Symfony\Component\Console\Command\Command;
  6. use Symfony\Component\Console\Input\InputInterface;
  7. use Symfony\Component\Console\Output\OutputInterface;
  8. use Symfony\Component\Console\Input\InputArgument;
  9. use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
  10. class MailerTestCommand extends Command
  11. {
  12. private $params;
  13. private $mailer;
  14. private $twig;
  15. public function __construct(
  16. ParameterBagInterface $params,
  17. \Swift_Mailer $mailer
  18. )
  19. {
  20. parent::__construct();
  21. $this->mailer = $mailer;
  22. $this->params = $params;
  23. }
  24. protected function configure()
  25. {
  26. $this
  27. ->setName('zitec:mailer:test')
  28. ->addArgument(
  29. 'emailaddress',
  30. InputArgument::REQUIRED,
  31. 'Email destination address. The origin address is configured as env parameter customer.care.email.sender'
  32. )
  33. ->setDescription('Send mail to specified address')
  34. ;
  35. }
  36. protected function execute(InputInterface $input, OutputInterface $output)
  37. {
  38. $to=$input->getArgument('emailaddress');
  39. $from=$this->params->get('customer.care.email.sender');
  40. $body = '<html><body><h1>Test Mail send to '.$to.' from '.$from.'</h1></body>';
  41. $message = new \Swift_Message('TestMail');
  42. $message->setSubject('Mailer Test')
  43. ->setFrom($from)
  44. ->setTo($to)
  45. ->setBody($body, 'text/html');
  46. $this->mailer->send($message);
  47. }
  48. }