My problem is that I'm trying to send a message from a command in Symfony 2 but it's all errors, this is my code:
$message = $this->mailer
->setFrom('[email protected]')
->setTo('[email protected]')
->setSubject('Subject')
->setBody('Body')
->attach($xml)
;
$this->mailer()->send($message);
The command class extends from the AbstractCommand which in turn extends from the ContainerAwareCommand, and the abstractCommand has a function to take the containers, and in it I have the following:
$this->mailer = $this->getContainer()->get('mailer');
And this is the error that it gives me when executing my command
Notice: Undefined property: Project \ Libraries \ ReportsBundle \ Command \ GenerateXMLCommand :: $ mailer
I would like to be able to be told a way to send messages from a Symfony 2 command.
Greetings. Thanks.