This topic contains 3 replies, has 2 voices, and was last updated by Mike Kudelya 7 years ago.
- Topic
I am a little confused about this feature. I follow the documentation https://oroinc.com/orocrm/documentation/2.0/book/sending-emails but the email that is sended is always empty.
For example I want to test it in a command :
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950<?phpnamespace Sinabs\Bundle\HotelBundle\Command;use Sinabs\Bundle\HotelBundle\Entity\Client;use Sinabs\Bundle\HotelBundle\Entity\Reservation;use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;use Symfony\Component\Console\Input\InputInterface;use Symfony\Component\Console\Output\OutputInterface;use Oro\Bundle\EmailBundle\Form\Model\Email;/*** Description of SendEmailCommand** @author adriwonkenobe*/class SendEmailCommand extends ContainerAwareCommand {const COMMAND_NAME = 'sinabs:send-email:test';protected function configure() {$this->setName(self::COMMAND_NAME);}protected function execute(InputInterface $input, OutputInterface $output) {$em = $this->getContainer()->get('doctrine.orm.entity_manager');$reservation = $em->getRepository("SinabsHotelBundle:Reservation")->findOneById(87);$email = new Email();// the sender$email->setFrom($this->getContainer()->get('oro_config.user')->get('oro_notification.email_notification_sender_email'));// recipient(s)$email->setTo(array($reservation->getClient()->getEmail()));// a template to create the e-mail body, the passed template// must be an instance of Oro\Bundle\EmailBundle\Entity\EmailTemplate$email->setTemplate($em->getRepository("OroEmailBundle:EmailTemplate")->findByName("hotel_accueil"));// a context that will be passed to the template set with setTemplate()$email->setContexts(array($reservation));$email->setType("html");$this->getContainer()->get('oro_email.mailer.processor')->process($email);}}
The forum ‘OroPlatform – Programming Questions’ is closed to new topics and replies.