/** * Send a message to a user * * @param string $user username * @param string $from from username * @param string $to to username (again?) * @param string $cc cc username * @param string $subject * @param string $body * @param int $priority * @param string $replyto_hash * @param string $replyto_email y/n * @param string $bcc_sender y/n send blind copy email to from user's * @return bool success */ function post_message($user, $from, $to, $cc, $subject, $body, $priority, $replyto_hash = '', $replyto_email = '', $bcc_sender = '') { global $prefs; $userlib = TikiLib::lib('user'); $smarty = TikiLib::lib('smarty'); $subject = strip_tags($subject); $body = strip_tags($body, '<a><b><img><i>'); // Prevent duplicates $hash = md5($subject . $body); if ($this->getOne('select count(*) from `messu_messages` where `user`=? and `user_from`=? and `hash`=?', array($user, $from, $hash))) { return false; } $query = 'insert into `messu_messages`' . ' (`user`, `user_from`, `user_to`, `user_cc`, `subject`, `body`, `date`' . ', `isRead`, `isReplied`, `isFlagged`, `priority`, `hash`, `replyto_hash`)' . ' values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)'; $this->query($query, array($user, $from, $to, $cc, $subject, $body, (int) $this->now, 'n', 'n', 'n', (int) $priority, $hash, $replyto_hash)); // Now check if the user should be notified by email $magId = $this->getOne('select LAST_INSERT_ID() from `messu_messages`', array()); $foo = parse_url($_SERVER['REQUEST_URI']); $machine = $this->httpPrefix(true) . $foo['path']; $machine = str_replace('messu-compose', 'messu-mailbox', $machine); $machine = str_replace('messu-broadcast', 'messu-mailbox', $machine); // For non-sefurl calls, replace tiki-ajax_services with messu-mailbox if // service called is user > send_message if ($foo['query'] == "controller=user&action=send_message") { $machine = str_replace('tiki-ajax_services', 'messu-mailbox', $machine); } //For sefurl service call user > send_message, redirect to messu-mailbox.php $machine = str_replace('tiki-user-send_message', 'messu-mailbox.php', $machine); if ($this->get_user_preference($user, 'minPrio', 6) <= $priority) { if (!isset($_SERVER['SERVER_NAME'])) { $_SERVER['SERVER_NAME'] = $_SERVER['HTTP_HOST']; } $email = $userlib->get_user_email($user); if ($userlib->user_exists($from)) { $from_email = $userlib->get_user_email($from); // $from_email required for TikiMail constructor } elseif ($from == 'tiki-contact.php' && !empty($prefs['sender_email'])) { $from_email = $prefs['sender_email']; } else { return false; // non-existent users can't send messages (etc) } if ($email) { include_once 'lib/webmail/tikimaillib.php'; $smarty->assign('mail_site', $_SERVER['SERVER_NAME']); $smarty->assign('mail_machine', $machine); $smarty->assign('mail_date', $this->now); $smarty->assign('mail_user', stripslashes($user)); $smarty->assign('mail_from', stripslashes($from)); $smarty->assign('mail_subject', stripslashes($subject)); $smarty->assign('mail_body', stripslashes($body)); $smarty->assign('mail_truncate', $prefs['messu_truncate_internal_message']); $smarty->assign('messageid', $magId); try { $mail = new TikiMail($user, $from_email); $lg = $this->get_user_preference($user, 'language', $prefs['site_language']); if (empty($subject)) { $s = $smarty->fetchLang($lg, 'mail/messu_message_notification_subject.tpl'); $mail->setSubject(sprintf($s, $_SERVER['SERVER_NAME'])); } else { $mail->setSubject($subject); } $mail_data = $smarty->fetchLang($lg, 'mail/messu_message_notification.tpl'); $mail->setText($mail_data); if ($from_email) { if ($bcc_sender === 'y' && !empty($from_email)) { $mail->setBcc($from_email); } if ($replyto_email !== 'y' && $userlib->get_user_preference($from, 'email is public', 'n') == 'n') { $from_email = ''; // empty $from_email if not to be used - saves getting it twice } if (!empty($from_email)) { $mail->setReplyTo($from_email); } } if (!$mail->send(array($email), 'mail')) { return false; //TODO echo $mail->errors; } } catch (Zend_Mail_Exception $e) { TikiLib::lib('errorreport')->report($e->getMessage()); return false; } } } return true; }
/** * * Sends a promotional email to the given recipients * @param string $sender Sender e-Mail address * @param string|array $recipients List of recipients either as array or comma/semi colon separated string * @param string $subject E-Mail subject * @param array $tokenlist * @internal param string $url_for_friend URL to share * @return bool true on success / false if the supplied parameters were incorrect/missing or an error occurred sending the mail */ function sendMail($sender, $recipients, $subject, $tokenlist = array()) { global $errors, $prefs, $smarty, $user, $userlib, $logslib; global $registrationlib; include_once 'lib/registration/registrationlib.php'; if (empty($sender)) { $errors[] = tra('Your email is mandatory'); return false; } if (function_exists('validate_email')) { $ok = validate_email($sender, $prefs['validateEmail']); } else { $ret = $registrationlib->SnowCheckMail($sender, '', 'mini'); $ok = $ret[0]; } if ($ok) { $from = str_replace(array("\r", "\n"), '', $sender); } else { $errors[] = tra('Invalid email') . ': ' . $_REQUEST['email']; return false; } $recipients = checkAddresses($recipients); if ($recipients === false) { return false; } include_once 'lib/webmail/tikimaillib.php'; $smarty->assign_by_ref('mail_site', $_SERVER['SERVER_NAME']); $applyFrom = !empty($user) && $from == $userlib->get_user_email($user); $ok = true; foreach ($recipients as $i => $recipient) { $mail = new TikiMail(); $mail->setSubject($subject); if ($applyFrom) { $mail->setFrom($from); $mail->setReplyTo("<{$from}>"); } if (count($tokenlist) > 1) { $url_for_friend = $tokenlist[$i]; } else { $url_for_friend = $tokenlist[0]; // only one token if not "subscribing" } $smarty->assign('url_for_friend', $url_for_friend); $txt = $smarty->fetch('mail/share.tpl'); // Rebuild email message texte $mail->setText($txt); $mailsent = $mail->send(array($recipient)); if (!$mailsent) { $errors[] = tra('Error sending mail to') . " {$recipient}"; $logslib->add_log('share', tra('Error sending mail to') . " {$recipient} " . tra('by') . ' ' . $user); } else { $logslib->add_log('share', tra('Share page') . ': ' . $url_for_friend . ' ' . tra('to') . ' ' . $recipient . ' ' . tra('by') . ' ' . $user); } $ok = $ok && $mailsent; } return $ok; }
/** * Send a message to a user with gpg-armor block etc included * A changed encryption-related version was copied/changed from lib/messu/messulib.pgp * into lib/openpgp/openpgplib.php for prepending/appending content into * message body * @param string $user * @param string $from * @param string $to * @param string $cc * @param string $subject * @param string $body * @param string $prepend_email_body * @param string $user_pubkeyarmor * @param string $priority * @param string $replyto_hash * @param string $replyto_email * @param string $bcc_sender * @access public * @return boolean true/false */ function post_message_with_pgparmor_attachment($user, $from, $to, $cc, $subject, $body, $prepend_email_body, $user_pubkeyarmor, $priority, $replyto_hash = '', $replyto_email = '', $bcc_sender = '') { global $prefs; $userlib = TikiLib::lib('user'); $tikilib = TikiLib::lib('tiki'); $smarty = TikiLib::lib('smarty'); $subject = strip_tags($subject); $body = strip_tags($body, '<a><b><img><i>'); // Prevent duplicates $hash = md5($subject . $body); if ($tikilib->getOne("select count(*) from `messu_messages` where `user`=? and `user_from`=? and `hash`=?", array($user, $from, $hash))) { return false; } $query = "insert into `messu_messages`(`user`,`user_from`,`user_to`,`user_cc`,`subject`,`body`,`date`,`isRead`,`isReplied`,`isFlagged`,`priority`,`hash`,`replyto_hash`) values(?,?,?,?,?,?,?,?,?,?,?,?,?)"; $tikilib->query($query, array($user, $from, $to, $cc, $subject, $body, (int) $tikilib->now, 'n', 'n', 'n', (int) $priority, $hash, $replyto_hash)); // Now check if the user should be notified by email $foo = parse_url($_SERVER["REQUEST_URI"]); $machine = $tikilib->httpPrefix(true) . $foo["path"]; $machine = str_replace('messu-compose', 'messu-mailbox', $machine); if ($tikilib->get_user_preference($user, 'minPrio', 6) <= $priority) { if (!isset($_SERVER["SERVER_NAME"])) { $_SERVER["SERVER_NAME"] = $_SERVER["HTTP_HOST"]; } $email = $userlib->get_user_email($user); if ($email) { include_once 'lib/webmail/tikimaillib.php'; $smarty->assign('mail_site', $_SERVER["SERVER_NAME"]); $smarty->assign('mail_machine', $machine); $smarty->assign('mail_date', $tikilib->now); $smarty->assign('mail_user', stripslashes($user)); $smarty->assign('mail_from', stripslashes($from)); $smarty->assign('mail_subject', stripslashes($subject)); //////////////////////////////////////////////////////////////////////// // // // ALPHAFIELDS 2012-11-03: ADDED PGP/MIME ENCRYPTION PREPARATION // // USING lib/openpgp/opepgplib.php // // // // prepend original headers into email // $aux_body = $prepend_email_body . $body; $body = $aux_body; // // //////////////////////////////////////////////////////////////////////// $smarty->assign('mail_body', stripslashes($body)); $mail = new TikiMail($user); $lg = $tikilib->get_user_preference($user, 'language', $prefs['site_language']); if (empty($subject)) { $s = $smarty->fetchLang($lg, 'mail/messu_message_notification_subject.tpl'); $mail->setSubject(sprintf($s, $_SERVER["SERVER_NAME"])); } else { $mail->setSubject($subject); } $mail_data = $smarty->fetchLang($lg, 'mail/messu_message_notification.tpl'); //////////////////////////////////////////////////////////////////////// // // // ALPHAFIELDS 2012-11-03: ADDED PGP/MIME ENCRYPTION PREPARATION // // USING lib/openpgp/opepgplib.php // // // // append pgparmor block and fingerprint into email // $mail_data .= $user_pubkeyarmor; // // //////////////////////////////////////////////////////////////////////// $mail->setText($mail_data); if ($userlib->user_exists($from)) { $from_email = $userlib->get_user_email($from); if ($bcc_sender === 'y' && !empty($from_email)) { $mail->setBcc($from_email); } if ($replyto_email !== 'y' && $userlib->get_user_preference($from, 'email is public', 'n') == 'n') { $from_email = ''; // empty $from_email if not to be used - saves getting it twice } if (!empty($from_email)) { $mail->setReplyTo($from_email); } } if (!empty($from_email)) { $mail->setFrom($from_email); } if (!$mail->send(array($email), 'mail')) { return false; //TODO echo $mail->errors; } } } return true; }
public function send_replace_item_notifications($args) { global $prefs, $user; // Don't send a notification if this operation is part of a bulk import if ($args['bulk_import']) { return; } $trackerId = $args['trackerId']; $itemId = $args['object']; $new_values = $args['values']; $old_values = $args['old_values']; $the_data = $this->generate_watch_data($old_values, $new_values, $trackerId, $itemId, $args['version']); if (empty($the_data) && $prefs['tracker_always_notify'] !== 'y') { return; } $tracker_definition = Tracker_Definition::get($trackerId); if (!$tracker_definition) { return; } $tracker_info = $tracker_definition->getInformation(); $watchers = $this->get_notification_emails($trackerId, $itemId, $tracker_info, $new_values['status'], $old_values['status']); if (count($watchers) > 0) { $simpleEmail = isset($tracker_info['simpleEmail']) ? $tracker_info['simpleEmail'] : "n"; $trackerName = $tracker_info['name']; if (!isset($_SERVER["SERVER_NAME"])) { $_SERVER["SERVER_NAME"] = $_SERVER["HTTP_HOST"]; } include_once 'lib/webmail/tikimaillib.php'; if ($simpleEmail == "n") { $mail_main_value_fieldId = $this->get_main_field($trackerId); $mail_main_value_field = $tracker_definition->getField($mail_main_value_fieldId); if ($mail_main_value_field['type'] == 'r') { // Item Link is special case as field value is not the displayed text. There might be other such field types. $handler = $this->get_field_handler($mail_main_value_field); $desc = $handler->getItemLabel($this->get_item_value($trackerId, $itemId, $mail_main_value_fieldId)); } else { $desc = $this->get_item_value($trackerId, $itemId, $mail_main_value_fieldId); } if ($tracker_info['doNotShowEmptyField'] === 'y') { // remove empty fields if tracker says so $the_data = preg_replace('/\\[-\\[.*?\\]-\\] -\\[\\(.*?\\)\\]-:\\n\\n----------\\n/', '', $the_data); } $smarty = TikiLib::lib('smarty'); $smarty->assign('mail_date', $this->now); $smarty->assign('mail_user', $user); $smarty->assign('mail_itemId', $itemId); $smarty->assign('mail_item_desc', $desc); $smarty->assign('mail_trackerId', $trackerId); $smarty->assign('mail_trackerName', $trackerName); $smarty->assign('server_name', $_SERVER['SERVER_NAME']); $foo = parse_url($_SERVER["REQUEST_URI"]); $machine = $this->httpPrefix(true) . $foo["path"]; $smarty->assign('mail_machine', $machine); $parts = explode('/', $foo['path']); if (count($parts) > 1) { unset($parts[count($parts) - 1]); } $smarty->assign('mail_machine_raw', $this->httpPrefix(true) . implode('/', $parts)); $smarty->assign_by_ref('status', $new_values['status']); foreach ($watchers as $watcher) { $watcher['language'] = $this->get_user_preference($watcher['user'], 'language', $prefs['site_language']); $label = $itemId ? tra('Item Modification', $watcher['language']) : tra('Item creation', $watcher['language']); $mail_action = "\r\n{$label}\r\n\r\n"; $mail_action .= tra('Tracker', $watcher['language']) . ":\n " . tra($trackerName, $watcher['language']) . "\r\n"; $mail_action .= tra('Item', $watcher['language']) . ":\n {$itemId} {$desc}"; $smarty->assign('mail_action', $mail_action); $subject = $smarty->fetchLang($watcher['language'], 'mail/tracker_changed_notification_subject.tpl'); list($watcher_data, $watcher_subject) = $this->translate_watch_data($the_data, $subject, $watcher['language']); $smarty->assign('mail_data', $watcher_data); if (isset($watcher['action'])) { $smarty->assign('mail_action', $watcher['action']); } $smarty->assign('mail_to_user', $watcher['user']); $mail_data = $smarty->fetchLang($watcher['language'], 'mail/tracker_changed_notification.tpl'); $mail = new TikiMail($watcher['user']); $mail->setSubject($watcher_subject); $mail->setText($mail_data); $mail->send(array($watcher['email'])); } } else { // Use simple email $foo = parse_url($_SERVER["REQUEST_URI"]); $machine = $this->httpPrefix(true) . $foo["path"]; $parts = explode('/', $foo['path']); if (count($parts) > 1) { unset($parts[count($parts) - 1]); } $machine = $this->httpPrefix(true) . implode('/', $parts); $userlib = TikiLib::lib('user'); if (!empty($user)) { $my_sender = $userlib->get_user_email($user); } else { // look if a email field exists $fieldId = $this->get_field_id_from_type($trackerId, 'm'); if (!empty($fieldId)) { $my_sender = $this->get_item_value($trackerId, $itemId, $fieldId); } } // Try to find a Subject in $the_data looking for strings marked "-[Subject]-" TODO: remove the tra (language translation by submitter) $the_string = '/^\\[-\\[' . tra('Subject') . '\\]-\\] -\\[[^\\]]*\\]-:\\n(.*)/m'; $subject_test_unchanged = preg_match($the_string, $the_data, $unchanged_matches); $the_string = '/^\\[-\\[' . tra('Subject') . '\\]-\\]:\\n(.*)\\n(.*)\\n\\n(.*)\\n(.*)/m'; $subject_test_changed = preg_match($the_string, $the_data, $matches); $subject = ''; if ($subject_test_unchanged == 1) { $subject = $unchanged_matches[1]; } if ($subject_test_changed == 1) { $subject = $matches[1] . ' ' . $matches[2] . ' ' . $matches[3] . ' ' . $matches[4]; } $i = 0; foreach ($watchers as $watcher) { $watcher['language'] = $this->get_user_preference($watcher['user'], 'language', $prefs['site_language']); $mail = new TikiMail($watcher['user']); list($watcher_data, $watcher_subject) = $this->translate_watch_data($the_data, $subject, $watcher['language']); $mail->setSubject('[' . $trackerName . '] ' . str_replace('> ', '', $watcher_subject) . ' (' . tra('Tracker was modified at %0 by %1', $watcher['language'], false, array($_SERVER["SERVER_NAME"], $user)) . ')'); $mail->setText(tra('View the tracker item at:', $watcher['language']) . " {$machine}/tiki-view_tracker_item.php?itemId={$itemId}\n\n" . $watcher_data); if (!empty($my_sender)) { $mail->setReplyTo($my_sender); } $mail->send(array($watcher['email'])); $i++; } } } }
/** \brief send the email notifications dealing with the forum changes to * \brief outbound address + admin notification addresses / forum admin email + watching users addresses * \param $event = 'forum_post_topic' or 'forum_post_thread' * \param $object = forumId watch if forum_post_topic or topicId watch if forum_post_thread * \param $threadId = topicId if forum_post_thread * \param $title of the message * \param $topicName name of the parent topic */ function sendForumEmailNotification($event, $object, $forum_info, $title, $data, $author, $topicName, $messageId = '', $inReplyTo = '', $threadId, $parentId, $contributions = '', $postId = '') { global $tikilib, $prefs, $smarty, $userlib; // Per-forum From address overrides global default. if ($forum_info['outbound_from']) { $author = $userlib->clean_user($author); $my_sender = '"' . "{$author}" . '" <' . $forum_info['outbound_from'] . '>'; } else { $my_sender = $prefs['sender_email']; } //outbound email -> will be sent in utf8 - from sender_email if ($forum_info['outbound_address']) { include_once 'lib/webmail/tikimaillib.php'; $mail = new TikiMail(); $mail->setSubject($title); if (!empty($forum_info['outbound_mails_reply_link']) && $forum_info['outbound_mails_reply_link'] == 'y') { $foo = parse_url($_SERVER["REQUEST_URI"]); $machine = $tikilib->httpPrefix(true) . dirname($foo["path"]); if ($event == 'forum_post_topic') { $reply_link = "{$machine}/tiki-view_forum_thread.php?forumId=" . $forum_info['forumId'] . "&comments_parentId={$threadId}#form"; } else { $reply_link = "{$machine}/tiki-view_forum_thread.php?forumId=" . $forum_info['forumId'] . "&comments_reply_threadId={$object}&comments_parentId={$threadId}&post_reply=1#form"; } } else { $reply_link = ''; } $smarty->assign('title', $title); $smarty->assign('data', $data); $smarty->assign('reply_link', $reply_link); $smarty->assign('author', $author); $mail_data = $smarty->fetch("mail/forum_outbound.tpl"); $mail->setText($mail_data); $mail->setReplyTo($my_sender); $mail->setFrom($my_sender); $mail->setSubject($topicName); if ($inReplyTo) { $mail->setHeader("In-Reply-To", "<" . $inReplyTo . ">"); } global $commentslib; $attachments = $commentslib->get_thread_attachments($event == 'forum_post_topic' ? $threadId : $object, 0); if (count($attachments) > 0) { foreach ($attachments as $att) { $att_data = $commentslib->get_thread_attachment($att['attId']); if ($att_data['dir'] . $att_data['path'] == "") { // no path to file on disk $file = $att_data['data']; // read file from database } else { $file = $mail->getFile($att_data['dir'] . $att_data['path']); // read file from disk } $mail->addAttachment($file, $att_data['filename'], $att_data['filetype']); } } // Message-ID is set below buildMessage because otherwise lib/webmail/htmlMimeMail.php will over-write it. $mail->setHeader("Message-ID", "<" . $messageId . ">"); $mail->send(array($forum_info['outbound_address'])); } $nots = array(); $defaultLanguage = $prefs['site_language']; // Users watching this forum or this post if ($prefs['feature_user_watches'] == 'y' || $prefs['feature_group_watches'] == 'y') { $nots_raw = $tikilib->get_event_watches($event, $event == 'forum_post_topic' ? $forum_info['forumId'] : $threadId, $forum_info); $nots = array(); $users = array(); foreach ($nots_raw as $n) { if ($n['user'] != $author && !in_array($n['user'], $users)) { // make sure user receive only one notification even if he is monitoring both the topic and thread $n['language'] = $tikilib->get_user_preference($n['user'], "language", $defaultLanguage); $nots[] = $n; $users[] = $n['user']; } } } // Special forward address //TODO: merge or use the admin notification feature if ($forum_info["useMail"] == 'y') { $not['email'] = $forum_info['mail']; if ($not['user'] = $userlib->get_user_by_email($forum_info['mail'])) { $not['language'] = $tikilib->get_user_preference($not['user'], "language", $defaultLanguage); } else { $not['language'] = $defaultLanguage; } $nots[] = $not; } if ($prefs['feature_user_watches'] == 'y' && $prefs['feature_daily_report_watches'] == 'y') { $reportsManager = Reports_Factory::build('Reports_Manager'); $reportsManager->addToCache($nots, array("event" => $event, "forumId" => $forum_info['forumId'], "forumName" => $forum_info['name'], "topicId" => $threadId, "threadId" => $postId, "threadName" => $topicName, "user" => $author)); } if (count($nots)) { include_once 'lib/webmail/tikimaillib.php'; $smarty->assign('mail_forum', $forum_info["name"]); $smarty->assign('mail_title', $title); $smarty->assign('mail_date', $tikilib->now); $smarty->assign('mail_message', $data); $smarty->assign('mail_author', $author); if ($prefs['feature_contribution'] == 'y' && !empty($contributions)) { global $contributionlib; include_once 'lib/contribution/contributionlib.php'; $smarty->assign('mail_contributions', $contributionlib->print_contributions($contributions)); } $foo = parse_url($_SERVER["REQUEST_URI"]); $machine = $tikilib->httpPrefix(true) . dirname($foo["path"]); $machine = preg_replace("!/\$!", "", $machine); // just incase $smarty->assign('mail_machine', $machine); $smarty->assign('forumId', $forum_info["forumId"]); if ($event == "forum_post_topic") { $smarty->assign('new_topic', 'y'); } else { $smarty->assign('threadId', $object); } $smarty->assign('topicId', $threadId); $smarty->assign('mail_topic', $topicName); foreach ($nots as $not) { $mail = new TikiMail(); $mail->setUser($not['user']); $mail_data = $smarty->fetchLang($not['language'], "mail/user_watch_forum_subject.tpl"); $mail->setSubject($mail_data); $mail_data = $smarty->fetchLang($not['language'], "mail/forum_post_notification.tpl"); $mail->setText($mail_data); $mail->send(array($not['email'])); } } }
private function send($email, $title, $html, $args = []) { global $prefs; require_once 'lib/webmail/tikimaillib.php'; $mail = new TikiMail(); $mail->setSubject($title); $mail->setHtml($html); if (!empty($prefs['monitor_reply_email_pattern']) && isset($args['reply_action'], $args['type'], $args['object'])) { $data = Tiki_Security::get()->encode(['u' => $GLOBALS['user'], 'a' => $args['reply_action'], 't' => $args['type'], 'o' => $args['object']]); $reply = str_replace('PLACEHOLDER', $data, $prefs['monitor_reply_email_pattern']); $name = tr("%0 Reply Handler", $prefs['sitetitle']); $mail->setReplyTo($reply, $name); } $mail->send($email); }
include_once 'lib/webmail/tikimaillib.php'; $smarty->assign_by_ref('mail_site', $_SERVER['SERVER_NAME']); if (isset($_REQUEST['report']) && $_REQUEST['report'] == 'y') { $subject = tra('Report to the webmaster', $prefs['site_language']); } else { $subject = $smarty->fetch('mail/tellAFriend_subject.tpl'); } // Generate once, unless token is required, in which case, regenrate per-message if ($prefs['auth_token_tellafriend'] != 'y' || $prefs['auth_token_access'] != 'y' || !isset($_POST['share_access'])) { $txt = $smarty->fetch('mail/tellAFriend.tpl'); } $ok = true; foreach ($emails as $email) { $mail = new TikiMail(); $mail->setFrom($from); $mail->setReplyTo($from); $mail->setSubject($subject); if ($prefs['auth_token_tellafriend'] == 'y' && $prefs['auth_token_access'] == 'y' && isset($_POST['share_access'])) { require_once 'lib/auth/tokens.php'; $tokenlib = AuthTokens::build($prefs); $url_for_friend = $tokenlib->includeToken($url_for_friend, $globalperms->getGroups()); $smarty->assign('url_for_friend', $url_for_friend); $txt = $smarty->fetch('mail/tellAFriend.tpl'); } $mail->setText($txt); $ok = $ok && $mail->send(array($email)); } if ($ok) { $access->redirect($_REQUEST['url'], tra('Your link was sent.')); } else { $errors = tra("The mail can't be sent. Contact the administrator");