I am currently working on a Symfony website hosted on an OVH server and I have some troubles. In fact, I am trying to create a command to send automatics emails. Then, I would like to use a cron to call this command 1 time by day but it is not the important part currently.
For the moment, I create a Mailer service that I tried in a test template and which work fine, but when I try to execute this code in a command, I have no error but the email is not sent and the only line I have in my log file is that:
event.DEBUG: Notified event "kernel.terminate" to listener "Symfony\Bundle\SwiftmailerBundle\EventListener\EmailSenderListener::onTerminate". [] []
I have no spool defined in my config file but even with one, the spool is always empty. I also heard about a conflict with DNSSEC but I have not access to this setting so I assumed that was not the reason of my problem.
So I tried to put away all potentials causes of errors and I restarted with the most basic solution:
class sendMailCommand extends ContainerAwareCommand {
protected function configure() {
$this
->setName('send:mail')
->setDescription('test send mail')
;
}
public function execute(InputInterface $input, OutputInterface $output) {
$mail = \Swift_Message::newInstance();
$mail
->setFrom('postmaster@mydomain.com')
->setSubject('test subject')
->setBody('test body')
->setTo('my-address@gmail.com');
$this->getContainer()->get('mailer')->send($mail);
}
}
But I obtained the same result. Do you have any idea of how to solve this problem? I also tried to make a command which call a youtube api but I didn't receive any data, may these two problems can be linked ? Need I to defined a particular context?
Thank you and sorry for my english ;) Victor