I have a Symfony2 command where I am sending some emails. Everything works fine except the fact that the email is sent as from the dev environement which uses the delivery_address by default.
Here is how it works:
- Call the command class from the /etc/crontab
-
The class will create the email and send it
$message = \Swift_Message::newInstance() ->setContentType("text/html") ->setSubject('Daily Digest of Comments, '.$runningConference['name_full']) ->setFrom('conferences@mdpi.com') ->setTo('email1@test.com') ->addBcc('email2@test.com'); $message->setBody($this->getContainer()->get('templating')->render('ProjectMyBundle:Page:paperCommentsDailyDigestEmailForSubscribers.txt.twig')); $this->getApplication()->getKernel()->getContainer()->get('mailer')->send($message);
-
Each minute, I am senting the email from files with a cronjob.
* * * * * www-data php /var/www/myproject/app/console swiftmailer:spool:send --env=prod