Пример #1
0
 function execute(JitFilter $data)
 {
     require_once 'lib/mail/maillib.php';
     try {
         $mail = tiki_get_admin_mail();
         if ($replyto = $data->replyto->email()) {
             $mail->setReplyTo($replyto);
         }
         foreach ($data->to->email() as $to) {
             $mail->addTo($this->stripNp($to));
         }
         foreach ($data->cc->email() as $cc) {
             $mail->addCc($this->stripNp($cc));
         }
         foreach ($data->bcc->email() as $bcc) {
             $mail->addBcc($this->stripNp($bcc));
         }
         $content = $this->parse($data->content->none());
         $subject = $this->parse($data->subject->text());
         $mail->setSubject(strip_tags($subject));
         $bodyPart = new \Zend\Mime\Message();
         $bodyMessage = new \Zend\Mime\Part($content);
         $bodyMessage->type = \Zend\Mime\Mime::TYPE_HTML;
         $bodyPart->setParts(array($bodyMessage));
         $mail->setBody($bodyPart);
         tiki_send_email($mail);
         return true;
     } catch (Exception $e) {
         return false;
     }
 }
Пример #2
0
 /**
  * @param null $user	to username
  * @param null $from	from email
  */
 function __construct($user = null, $from = null)
 {
     require_once 'lib/mail/maillib.php';
     $userlib = TikiLib::lib('user');
     $to = '';
     if (!empty($user)) {
         if ($userlib->user_exists($user)) {
             $to = $userlib->get_user_email($user);
         } else {
             trigger_error('User not found');
             return;
         }
     }
     if (!empty($from)) {
         $this->mail = tiki_get_basic_mail();
         try {
             $this->mail->setFrom($from);
             $this->mail->setReturnPath($from);
         } catch (Exception $e) {
             // was already set, then do nothing
         }
     } else {
         $this->mail = tiki_get_admin_mail();
     }
     if (!empty($to)) {
         $this->mail->addTo($to);
     }
 }
Пример #3
0
 function execute(JitFilter $data)
 {
     require_once 'lib/mail/maillib.php';
     try {
         $mail = tiki_get_admin_mail();
         if ($replyto = $data->replyto->email()) {
             $mail->setReplyTo($replyto);
         }
         foreach ($data->to->email() as $to) {
             $mail->addTo($this->stripNp($to));
         }
         foreach ($data->cc->email() as $cc) {
             $mail->addCc($this->stripNp($cc));
         }
         foreach ($data->bcc->email() as $bcc) {
             $mail->addBcc($this->stripNp($bcc));
         }
         $content = $this->parse($data->content->none());
         $subject = $this->parse($data->subject->text());
         $mail->setSubject(strip_tags($subject));
         $mail->setBodyHtml($content);
         $mail->send();
         return true;
     } catch (Exception $e) {
         return false;
     }
 }
Пример #4
0
 private function get_edition_mail($editionId, $target, $is_html = null)
 {
     global $prefs, $base_url;
     static $mailcache = array();
     if (!isset($mailcache[$editionId])) {
         $tikilib = TikiLib::lib('tiki');
         $headerlib = TikiLib::lib('header');
         $info = $this->get_edition($editionId);
         $nl_info = $this->get_newsletter($info['nlId']);
         // build the html
         $beginHtml = '<body class="tiki_newsletters"><div id="tiki-center" class="clearfix content"><div class="wikitext">';
         $endHtml = '</div></div></body>';
         if ($is_html === null) {
             $is_html = $info['wysiwyg'] === 'y' && $prefs['wysiwyg_htmltowiki'] !== 'y';
             // parse as html if wysiwyg and not htmltowiki
         } else {
             $is_html = !empty($is_html);
         }
         if (stristr($info['data'], '<body') === false) {
             $html = "<html>{$beginHtml}" . $tikilib->parse_data($info['data'], array('absolute_links' => true, 'suppress_icons' => true, 'is_html' => $is_html)) . "{$endHtml}</html>";
         } else {
             $html = str_ireplace('<body>', $beginHtml, $info['data']);
             $html = str_ireplace('</body>', $endHtml, $html);
         }
         if ($nl_info['allowArticleClip'] == 'y' && $nl_info['autoArticleClip'] == 'y') {
             $articleClip = $this->clip_articles($nl_info['nlId']);
             $txtArticleClip = $this->generateTxtVersion($articleClip);
             $info['datatxt'] = str_replace('~~~articleclip~~~', $txtArticleClip, $info['datatxt']);
             $html = str_replace('~~~articleclip~~~', $articleClip, $html);
             if ($articleClip == '<div class="articleclip"></div>' && $nl_info['emptyClipBlocksSend'] == 'y') {
                 return '';
             }
         }
         if (stristr($html, '<base') === false) {
             if (stristr($html, '<head') === false) {
                 $news_cssfile = $tikilib->get_style_path($prefs['style'], '', 'newsletter.css');
                 $news_cssfile_option = $tikilib->get_style_path($prefs['style'], $prefs['style_option'], 'newsletter.css');
                 $news_css = '';
                 if (!empty($news_cssfile)) {
                     $news_css .= $headerlib->minify_css($news_cssfile);
                 }
                 if (!empty($news_cssfile_option) && $news_cssfile_option !== $news_cssfile) {
                     $news_css .= $headerlib->minify_css($news_cssfile_option);
                 }
                 if (empty($news_css)) {
                     $news_css = $headerlib->get_all_css_content();
                 }
                 $news_head = "<html><head><base href=\"{$base_url}\" /><style type=\"text/css\">{$news_css}</style></head>";
                 $html = str_ireplace('<html>', $news_head, $html);
             } else {
                 $html = str_ireplace('<head>', "<head><base href=\"{$base_url}\" />", $html);
             }
         }
         $info['files'] = $this->get_edition_files($editionId);
         include_once 'lib/mail/maillib.php';
         $zmail = tiki_get_admin_mail();
         if (!empty($info['replyto'])) {
             $zmail->setReplyTo($info['replyto']);
         }
         foreach ($info['files'] as $f) {
             $fpath = isset($f['path']) ? $f['path'] : $prefs['tmpDir'] . '/newsletterfile-' . $f['filename'];
             $att = $zmail->createAttachment(file_get_contents($fpath));
             $att->filename = $f['name'];
             $att->mimeType = $f['type'];
         }
         $zmail->setSubject($info['subject']);
         $mailcache[$editionId] = array('zmail' => $zmail, 'text' => $info['datatxt'], 'html' => $html, 'unsubMsg' => $nl_info['unsubMsg'], 'nlId' => $nl_info['nlId']);
     }
     $cache = $mailcache[$editionId];
     $html = $cache['html'];
     $unsubmsg = '';
     if ($cache["unsubMsg"] == 'y' && !empty($target["code"])) {
         $unsubmsg = $this->get_unsub_msg($cache["nlId"], $target['email'], $target['language'], $target["code"], $target['user']);
         if (stristr($html, '</body>') === false) {
             $html .= $unsubmsg;
         } else {
             $html = str_replace("</body>", nl2br($unsubmsg) . "</body>", $html);
         }
     }
     $zmail = $cache['zmail'];
     $zmail->setBodyHtml($html);
     $zmail->setBodyText($cache['text'] . strip_tags($unsubmsg));
     $zmail->clearRecipients();
     $zmail->addTo($target['email']);
     return $zmail;
 }
Пример #5
0
/**
 * @param $email
 * @param $recipientName
 * @param $subject
 * @param $textBody
 */
function tiki_send_admin_mail($email, $recipientName, $subject, $textBody)
{
    $mail = tiki_get_admin_mail();
    $mail->addTo($email, $recipientName);
    $mail->setSubject($subject);
    $mail->setBody($textBody);
    tiki_send_email($mail);
}