Beispiel #1
0
 /**
  * Generates and sends an E-mail
  *
  * @param string $recipientName
  * @param string $recipientEmail
  * @param string $from
  * @param string $subject
  * @param string $body
  * @param string $mailSignature
  *
  * @return bool
  */
 public function execute($recipientName, $recipientEmail, $from, $subject, $body, $mailSignature = '')
 {
     if (!empty($recipientName)) {
         $to = ['name' => $recipientName, 'email' => $recipientEmail];
     } else {
         $to = $recipientEmail;
     }
     return $this->mailer->reset()->setSubject($subject)->setBody($body)->setMailSignature($mailSignature)->setFrom($from)->setRecipients($to)->send();
 }
 /**
  * Versendet einen Newsletter
  *
  * @param int $newsletterId
  * @param string|array $recipients
  * @param bool $bcc
  *
  * @return bool
  */
 public function sendNewsletter($newsletterId, $recipients, $bcc = false)
 {
     $settings = $this->config->getSettings(Schema::MODULE_NAME);
     $newsletter = $this->newsletterRepository->getOneById($newsletterId);
     $sender = ['email' => $settings['mail'], 'name' => $this->config->getSettings(\ACP3\Modules\ACP3\System\Installer\Schema::MODULE_NAME)['site_title']];
     $this->mailer->reset()->setBcc($bcc)->setFrom($sender)->setSubject($newsletter['title'])->setUrlWeb($this->router->route('newsletter/archive/details/id_' . $newsletterId, true))->setMailSignature($settings['mailsig']);
     if ($newsletter['html'] == 1) {
         $this->mailer->setTemplate('newsletter/layout.email.tpl');
         $this->mailer->setHtmlBody($newsletter['text']);
     } else {
         $this->mailer->setBody($newsletter['text']);
     }
     $this->mailer->setRecipients($recipients);
     return $this->mailer->send();
 }
Beispiel #3
0
 /**
  * @param string $emailAddress
  * @param string $hash
  *
  * @return bool
  */
 protected function sendDoubleOptInEmail($emailAddress, $hash)
 {
     $url = $this->router->route('newsletter/index/activate/hash_' . $hash, true);
     $systemSettings = $this->config->getSettings(\ACP3\Modules\ACP3\System\Installer\Schema::MODULE_NAME);
     $settings = $this->config->getSettings(Schema::MODULE_NAME);
     $subject = $this->translator->t('newsletter', 'subscribe_mail_subject', ['%title%' => $systemSettings['site_title']]);
     $body = $this->translator->t('newsletter', 'subscribe_mail_body', ['{host}' => $this->request->getHost()]) . "\n\n";
     $from = ['email' => $settings['mail'], 'name' => $systemSettings['site_title']];
     $this->mailer->reset()->setFrom($from)->setSubject($subject)->setMailSignature($settings['mailsig']);
     if ($settings['html'] == 1) {
         $this->mailer->setTemplate('newsletter/layout.email.tpl');
         $body .= '<a href="' . $url . '">' . $url . '<a>';
         $this->mailer->setHtmlBody($this->stringFormatter->nl2p($body));
     } else {
         $body .= $url;
         $this->mailer->setBody($body);
     }
     $this->mailer->setRecipients($emailAddress);
     return $this->mailer->send();
 }