Exemplo n.º 1
0
 /**
  * If date is specified, the it sent at that time
  * @param \ClassCentral\SiteBundle\Entity\Newsletter $newsLetter
  * @param $html
  * @param $date
  */
 public function sendNewsletter(\ClassCentral\SiteBundle\Entity\Newsletter $newsLetter, $html, $subject, \DateTime $date = null, $deliveryTime)
 {
     $listAddress = $this->getListAddress($newsLetter->getCode());
     try {
         $params = array('from' => 'Class Central <newsletter@' . $this->mailDomain . '>', 'to' => $listAddress, 'subject' => $subject, 'html' => $html, 'o:campaign' => $newsLetter->getCode(), 'o:deliverytime' => $deliveryTime);
         if ($date) {
             // TODO: Add date to params
         }
         $result = $this->mailgun->sendMessage($this->mailDomain, $params);
         return $result->http_response_code == 200;
     } catch (\Exception $e) {
         // Log the error
         return false;
     }
 }
Exemplo n.º 2
0
 /**
  * Signs up for a newsletter
  */
 public function subscribe(\ClassCentral\SiteBundle\Entity\Newsletter $newsletter)
 {
     $signedUp = false;
     foreach ($this->getNewsletters() as $ns) {
         if ($ns->getCode() == $newsletter->getCode()) {
             $signedUp = true;
             break;
         }
     }
     if (!$signedUp) {
         $this->addNewsletter($newsletter);
     }
 }