0

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

pom
  • 28
  • 4
  • If you try to copy-paste all code to send emails in a regular controller, then you call the controller what Happend ? Did you check you spam ? OVH require a smtp authentification, did you disabled it ? – Arthur BALAGNE Jul 31 '14 at 12:47
  • Thank you for your quick reply. Yes this code works in a controller, the only difference is the calling to the mailer service (`$this->getContainer()->get('mailer')` for the command and `$this->get('mailer')` for the controller). And for the smtp authentification I did not find the option to disable it, but as the authentification is configure in configs files and emails working fine with controllers, I guessed that will not be the raison of my problem. – pom Aug 01 '14 at 07:48

0 Answers0