/**
  * Helper function for sending a mail
  *
  * @author Adrian Lang <*****@*****.**>
  *
  * @param string $subscriber_mail The target mail address
  * @param string $subject         The lang id of the mail subject (without the
  *                                prefix “mail_”)
  * @param string $context         The context of this mail, eg. page or namespace id
  * @param string $template        The name of the mail template
  * @param array  $trep            Predefined parameters used to parse the
  *                                template (in text format)
  * @param array  $hrep            Predefined parameters used to parse the
  *                                template (in HTML format), null to default to $trep
  * @param array  $headers         Additional mail headers in the form 'name' => 'value'
  * @return bool
  */
 protected function send($subscriber_mail, $subject, $context, $template, $trep, $hrep = null, $headers = array())
 {
     global $lang;
     global $conf;
     $text = rawLocale($template);
     $subject = $lang['mail_' . $subject] . ' ' . $context;
     $mail = new Mailer();
     $mail->bcc($subscriber_mail);
     $mail->subject($subject);
     $mail->setBody($text, $trep, $hrep);
     if (in_array($template, array('subscr_list', 'subscr_digest'))) {
         $mail->from($conf['mailfromnobody']);
     }
     if (isset($trep['SUBSCRIBE'])) {
         $mail->setHeader('List-Unsubscribe', '<' . $trep['SUBSCRIBE'] . '>', false);
     }
     foreach ($headers as $header => $value) {
         $mail->setHeader($header, $value);
     }
     return $mail->send();
 }
Beispiel #2
0
/**
 * Sends a notify mail on page change or registration
 *
 * @param string     $id       The changed page
 * @param string     $who      Who to notify (admin|subscribers|register)
 * @param int|string $rev Old page revision
 * @param string     $summary  What changed
 * @param boolean    $minor    Is this a minor edit?
 * @param array      $replace  Additional string substitutions, @KEY@ to be replaced by value
 *
 * @return bool
 * @author Andreas Gohr <*****@*****.**>
 */
function notify($id, $who, $rev = '', $summary = '', $minor = false, $replace = array())
{
    global $lang;
    global $conf;
    global $INFO;
    global $DIFF_INLINESTYLES;
    // decide if there is something to do, eg. whom to mail
    if ($who == 'admin') {
        if (empty($conf['notify'])) {
            return false;
        }
        //notify enabled?
        $text = rawLocale('mailtext');
        $to = $conf['notify'];
        $bcc = '';
    } elseif ($who == 'subscribers') {
        if (!$conf['subscribers']) {
            return false;
        }
        //subscribers enabled?
        if ($conf['useacl'] && $_SERVER['REMOTE_USER'] && $minor) {
            return false;
        }
        //skip minors
        $data = array('id' => $id, 'addresslist' => '', 'self' => false);
        trigger_event('COMMON_NOTIFY_ADDRESSLIST', $data, 'subscription_addresslist');
        $bcc = $data['addresslist'];
        if (empty($bcc)) {
            return false;
        }
        $to = '';
        $text = rawLocale('subscr_single');
    } elseif ($who == 'register') {
        if (empty($conf['registernotify'])) {
            return false;
        }
        $text = rawLocale('registermail');
        $to = $conf['registernotify'];
        $bcc = '';
    } else {
        return false;
        //just to be safe
    }
    // prepare replacements (keys not set in hrep will be taken from trep)
    $trep = array('NEWPAGE' => wl($id, '', true, '&'), 'PAGE' => $id, 'SUMMARY' => $summary);
    $trep = array_merge($trep, $replace);
    $hrep = array();
    // prepare content
    if ($who == 'register') {
        $subject = $lang['mail_new_user'] . ' ' . $summary;
    } elseif ($rev) {
        $subject = $lang['mail_changed'] . ' ' . $id;
        $trep['OLDPAGE'] = wl($id, "rev={$rev}", true, '&');
        $df = new Diff(explode("\n", rawWiki($id, $rev)), explode("\n", rawWiki($id)));
        $dformat = new UnifiedDiffFormatter();
        $tdiff = $dformat->format($df);
        $DIFF_INLINESTYLES = true;
        $dformat = new InlineDiffFormatter();
        $hdiff = $dformat->format($df);
        $hdiff = '<table>' . $hdiff . '</table>';
        $DIFF_INLINESTYLES = false;
    } else {
        $subject = $lang['mail_newpage'] . ' ' . $id;
        $trep['OLDPAGE'] = '---';
        $tdiff = rawWiki($id);
        $hdiff = nl2br(hsc($tdiff));
    }
    $trep['DIFF'] = $tdiff;
    $hrep['DIFF'] = $hdiff;
    // send mail
    $mail = new Mailer();
    $mail->to($to);
    $mail->bcc($bcc);
    $mail->subject($subject);
    $mail->setBody($text, $trep, $hrep);
    if ($who == 'subscribers') {
        $mail->setHeader('List-Unsubscribe', '<' . wl($id, array('do' => 'subscribe'), true, '&') . '>', false);
    }
    return $mail->send();
}
 /**
  * Send approve-mail to editor of the now approved revision
  *
  * @return bool false if there was an error passing the mail to the MTA
  */
 public function send_approve_mail()
 {
     global $ID;
     global $REV;
     /** @var DokuWiki_Auth_Plugin $auth */
     global $auth;
     $data = pageinfo();
     // get mail receiver
     if (!$REV) {
         $rev = $data['lastmod'];
     } else {
         $rev = $REV;
     }
     $changelog = new PageChangelog($ID);
     $revinfo = $changelog->getRevisionInfo($rev);
     $userinfo = $auth->getUserData($revinfo['user']);
     $receiver = $userinfo['mail'];
     // get mail sender
     $ReplyTo = $data['userinfo']['mail'];
     if ($ReplyTo == $receiver) {
         return true;
     }
     // get mail subject
     $subject = $this->getLang('apr_mail_app_subject');
     // get mail text
     $body = $this->create_mail_body('approve');
     $mail = new Mailer();
     $mail->to($receiver);
     $mail->subject($subject);
     $mail->setBody($body);
     $mail->setHeader("Reply-To", $ReplyTo);
     $returnStatus = $mail->send();
     return $returnStatus;
 }
Beispiel #4
0
/**
 * Helper function for sending a mail
 *
 * @param string $subscriber_mail The target mail address
 * @param array  $replaces        Predefined parameters used to parse the
 *                                template
 * @param string $subject         The lang id of the mail subject (without the
 *                                prefix “mail_”)
 * @param string $id              The page or namespace id
 * @param string $template        The name of the mail template
 *
 * @author Adrian Lang <*****@*****.**>
 */
function subscription_send($subscriber_mail, $replaces, $subject, $id, $template)
{
    global $conf;
    global $lang;
    $text = rawLocale($template);
    $trep = array_merge($replaces, array('PAGE' => $id));
    $subject = $lang['mail_' . $subject] . ' ' . $id;
    $mail = new Mailer();
    $mail->bcc($subscriber_mail);
    $mail->subject($subject);
    $mail->setBody($text, $trep);
    $mail->setHeader('List-Unsubscribe', '<' . wl($id, array('do' => 'subscribe'), true, '&') . '>', false);
    return $mail->send();
}
Beispiel #5
0
/**
 * Helper function for sending a mail
 *
 * @author Adrian Lang <*****@*****.**>
 *
 * @param string $subscriber_mail The target mail address
 * @param array  $replaces        Predefined parameters used to parse the
 *                                template
 * @param string $subject         The lang id of the mail subject (without the
 *                                prefix “mail_”)
 * @param string $id              The page or namespace id
 * @param string $template        The name of the mail template
 * @return bool
 */
function subscription_send($subscriber_mail, $replaces, $subject, $id, $template)
{
    global $lang;
    global $conf;
    $text = rawLocale($template);
    $trep = array_merge($replaces, array('PAGE' => $id));
    $hrep = $trep;
    $hrep['DIFF'] = nl2br(htmlspecialchars($hrep['DIFF']));
    $subject = $lang['mail_' . $subject] . ' ' . $id;
    $mail = new Mailer();
    $mail->bcc($subscriber_mail);
    $mail->subject($subject);
    $mail->setBody($text, $trep, $hrep);
    $mail->from($conf['mailfromnobody']);
    $mail->setHeader('List-Unsubscribe', '<' . wl($id, array('do' => 'subscribe'), true, '&') . '>', false);
    return $mail->send();
}