protected function sendEmail(Letter $letter, ContactGroup $contactGroup, $callback = null) { $stmt = $this->em->getConnection()->prepare('select contact_id from orocrm_contact_to_contact_grp where contact_group_id = :group_id'); $stmt->bindValue(':group_id', $contactGroup->getId()); $stmt->execute(); $contactIds = $stmt->fetchAll(); if (!count($contactIds)) { echo sprintf('No Contacts Found in Group %s', $contactGroup->getLabel()); exit; } foreach ($contactIds as $contactId) { $contact = $this->em->getRepository('OroCRMContactBundle:Contact')->find($contactId['contact_id']); $email = $contact->getEmail(); $message = \Swift_Message::newInstance()->setSubject($letter->getSubject())->setFrom('*****@*****.**', 'Vladimir Drizheruk')->setTo('*****@*****.**')->setBody($letter->getBody(), 'text/html'); if ($this->mailer->send($message)) { echo sprintf("Send to %s", $email) . PHP_EOL . PHP_EOL; } unset($email); unset($message); } }
public function testBeforeUpdate() { $obj = new Letter(); $this->assertNull($obj->getCreatedAt()); $this->assertNull($obj->getUpdatedAt()); $obj->preUpdate(); $this->assertInstanceOf('\\DateTime', $obj->getUpdatedAt()); $this->assertNull($obj->getCreatedAt()); }