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.
56 lines
1.6 KiB
56 lines
1.6 KiB
<?php
|
|
|
|
|
|
namespace Zitec\RuleEngineBundle\Command;
|
|
|
|
use Twig\Environment;
|
|
use Doctrine\ORM\EntityManagerInterface;
|
|
use Symfony\Component\Console\Command\Command;
|
|
use Symfony\Component\Console\Input\InputInterface;
|
|
use Symfony\Component\Console\Output\OutputInterface;
|
|
use Symfony\Component\Console\Input\InputArgument;
|
|
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
|
|
|
|
class MailerTestCommand extends Command
|
|
{
|
|
|
|
private $params;
|
|
private $mailer;
|
|
private $twig;
|
|
|
|
public function __construct(
|
|
ParameterBagInterface $params,
|
|
\Swift_Mailer $mailer
|
|
)
|
|
{
|
|
parent::__construct();
|
|
$this->mailer = $mailer;
|
|
$this->params = $params;
|
|
}
|
|
protected function configure()
|
|
{
|
|
$this
|
|
->setName('zitec:mailer:test')
|
|
->addArgument(
|
|
'emailaddress',
|
|
InputArgument::REQUIRED,
|
|
'Email destination address. The origin address is configured as env parameter customer.care.email.sender'
|
|
)
|
|
->setDescription('Send mail to specified address')
|
|
;
|
|
}
|
|
protected function execute(InputInterface $input, OutputInterface $output)
|
|
{
|
|
$to=$input->getArgument('emailaddress');
|
|
$from=$this->params->get('customer.care.email.sender');
|
|
$body = '<html><body><h1>Test Mail send to '.$to.' from '.$from.'</h1></body>';
|
|
|
|
$message = new \Swift_Message('TestMail');
|
|
$message->setSubject('Mailer Test')
|
|
->setFrom($from)
|
|
->setTo($to)
|
|
->setBody($body, 'text/html');
|
|
$this->mailer->send($message);
|
|
|
|
}
|
|
}
|