Exemple #1
0
 /**
  * @param Subscriber $subscriber
  * @param Campaign   $campaign
  * @param string     $subject
  * @param string     $body
  * @param array      $headerLines
  */
 protected function mail(Subscriber $subscriber, Campaign $campaign, $subject, $body, $headerLines = [])
 {
     $mail = $this->sxMail->compose($body);
     $mail->setSender($campaign->getSenderAddress())->setTo($subscriber->getEmailAddress())->setSubject($subject);
     if ($campaign->getFromAddress()) {
         $mail->setFrom($campaign->getFromAddress());
     }
     if ($campaign->getReplyToAddress()) {
         $mail->setReplyTo($campaign->getReplyToAddress());
     }
     foreach ($headerLines as $headerLine) {
         $mail->getHeaders()->addHeaderLine($headerLine);
     }
     $this->sxMail->send($mail);
 }
Exemple #2
0
 /**
  * @param  Entity\Note $note
  * @param  array $users
  * @param  Entity\User $owner
  * @param  string $subject
  * @param  string $title
  * @return void
  */
 protected function sendNoteGroupMail(Entity\Note $note, array $users, Entity\User $owner, $subject, $title)
 {
     /** @var Entity\User $user */
     foreach ($users as $user) {
         if ($user->getId() != $owner->getId() && true === $user->getNotifications()) {
             $this->translator->setLocale($user->getLanguage());
             $subject = $this->translator->translate($subject);
             $content = new ViewModel();
             $content->setTemplate('mail/note.phtml')->setVariable('title', $title)->setVariable('note', $note)->setVariable('host', $this->host);
             $message = $this->SxMail->compose($content);
             $message->addTo($user->getEmail());
             $message->addFrom($this->defaultFrom);
             $message->setSubject($subject);
             $this->SxMail->send($message);
         }
     }
     // @todo this will only work, as long owner is the only one with edit permissions
     $this->translator->setLocale($owner->getLanguage());
     return;
 }