private function sendMail($from_user, $to_address, $to_name)
 {
     global $wgSitename;
     $subject = wfMsg('newuseremailnotification-subject', $wgSitename);
     $body = wfMsg('newuseremailnotification-body', $wgSitename, $from_user->mName, $from_user->mRealName);
     $to = new MailAddress($to_address, $to_name);
     $sender = new MailAddress($from_user);
     $error = userMailer($to, $sender, $subject, $body);
 }
Пример #2
0
 function notifyRequest($titleObj, $actualTitleObj)
 {
     global $wgUser, $wgServer, $wgScriptPath, $wgScript;
     $dbkey = $titleObj->getDBKey();
     if ($actualTitleObj != null) {
         $dbkey = $actualTitleObj->getDBKey();
     }
     //$sql = "SELECT user_name, user_real_name, user_email from page, revision, user where rev_user=user_id and page_namespace = " . NS_ARTICLE_REQUEST . " and page_title='" . $dbkey . "' and rev_page = page_id;";
     $author_name = "";
     if ($wgUser->getID() > 0) {
         $author_name = $wgUser->getRealName();
         if ($author_name == "") {
             $author_name = $wgUser->getName();
         }
     }
     $subject = wfMsg('howto', $titleObj->getText());
     $text = wfMsg('howto', $titleObj->getText()) . "\n\n";
     if ($wgUser->getID() > 0) {
         $text = wfMsg('request_answered_email_by_logged_in_user', $titleObj->getText(), $wgServer . $wgScriptPath . "/" . $titleObj->getDBKey(), $author_name, $wgServer . $wgScriptPath . "/User_talk:" . $wgUser->getName());
     } else {
         $text = wfMsg('request_answered_email', $titleObj->getText(), $wgServer . $wgScriptPath . "/" . $titleObj->getDBKey());
     }
     $dbr =& wfGetDB(DB_READ);
     $res = $dbr->select(array('page', 'revision', 'user'), array('user_name', 'user_real_name', 'user_email'), array('rev_user=user_id', 'page_namespace=' . NS_ARTICLE_REQUEST, 'page_title' => $dbkey, 'rev_page=page_id'), "notifyRequest", array('ORDER BY' => 'rev_id', 'LIMIT' => 1));
     while (($row = $dbr->fetchObject($res)) != NULL) {
         $name = $row->user_real_name;
         if ($name == "") {
             $name = $row->user_name;
         }
         $email = $row->user_email;
         if ($email != "") {
             $to = new MailAddress($email);
             $from = new MailAddress("\"wikiHow\" <*****@*****.**>");
             $mailResult = userMailer($to, $from, wfQuotedPrintable($subject), $text, false);
         }
     }
     $dbr->freeResult($res);
 }
Пример #3
0
 function notifyRequest($titleObj, $actualTitleObj)
 {
     global $wgUser, $wgServer, $wgScriptPath, $wgScript;
     $dbkey = $titleObj->getDBKey();
     if ($actualTitleObj) {
         $dbkey = $actualTitleObj->getDBKey();
     }
     $author_name = "";
     if ($wgUser->getID() > 0) {
         $author_name = $wgUser->getRealName();
         if (!$author_name) {
             $author_name = $wgUser->getName();
         }
     }
     $subject = wfMsg('howto', $titleObj->getText());
     $text = wfMsg('howto', $titleObj->getText()) . "\n\n";
     if ($wgUser->getID() > 0) {
         $text = wfMsg('request_answered_email_by_logged_in_user', $titleObj->getText(), $wgServer . $wgScriptPath . "/" . $titleObj->getDBKey(), $author_name, $wgServer . $wgScriptPath . "/User_talk:" . $wgUser->getName());
     } else {
         $text = wfMsg('request_answered_email', $titleObj->getText(), $wgServer . $wgScriptPath . "/" . $titleObj->getDBKey());
     }
     $dbr = wfGetDB(DB_READ);
     $res = $dbr->select(array('page', 'revision', 'user'), array('user_name', 'user_real_name', 'user_email'), array('rev_user=user_id', 'page_namespace=' . NS_ARTICLE_REQUEST, 'page_title' => $dbkey, 'rev_page=page_id'), __METHOD__, array('ORDER BY' => 'rev_id', 'LIMIT' => 1));
     foreach ($res as $row) {
         $name = $row->user_real_name;
         if (!$name) {
             $name = $row->user_name;
         }
         $email = $row->user_email;
         if ($email) {
             $to = new MailAddress($email);
             $from = new MailAddress('"wikiHow" <*****@*****.**>');
             $mailResult = userMailer($to, $from, wfQuotedPrintable($subject), $text, false);
         }
     }
     $dbr->freeResult($res);
 }
Пример #4
0
 /**
  * Send an e-mail to this user's account. Does not check for
  * confirmed status or validity.
  *
  * @param string $subject
  * @param string $body
  * @param strong $from Optional from address; default $wgPasswordSender will be used otherwise.
  * @return mixed True on success, a WikiError object on failure.
  */
 function sendMail($subject, $body, $from = null)
 {
     if (is_null($from)) {
         global $wgPasswordSender;
         $from = $wgPasswordSender;
     }
     require_once 'UserMailer.php';
     $to = new MailAddress($this);
     $sender = new MailAddress($from);
     $error = userMailer($to, $sender, $subject, $body);
     if ($error == '') {
         return true;
     } else {
         return new WikiError($error);
     }
 }
Пример #5
0
 /**
  * Send email to external addresses
  */
 function sendExternalMails()
 {
     global $wgNewUserNotifEmailTargets, $wgContLang;
     foreach ($wgNewUserNotifEmailTargets as $target) {
         $message = $this->makeMessage($target, $this->user);
         userMailer($this->mailAddress($target), $this->mailAddress($this->sender), $this->makeSubject(), $message);
     }
 }
Пример #6
0
 function doSubmit()
 {
     global $wgOut, $wgUser;
     $to = new MailAddress($this->target);
     $from = new MailAddress($wgUser);
     $subject = $this->subject;
     if (wfRunHooks('EmailUser', array(&$to, &$from, &$subject, &$this->text))) {
         $mailResult = userMailer($to, $from, $subject, $this->text);
         if (WikiError::isError($mailResult)) {
             $wgOut->addHTML(wfMsg("usermailererror") . $mailResult);
         } else {
             $titleObj = Title::makeTitle(NS_SPECIAL, "Emailuser");
             $encTarget = wfUrlencode($this->target->getName());
             $wgOut->redirect($titleObj->getFullURL("target={$encTarget}&action=success"));
             wfRunHooks('EmailUserComplete', array($to, $from, $subject, $this->text));
         }
     }
 }
Пример #7
0
 function execute($par)
 {
     global $wgUser, $wgOut, $wgLang, $wgTitle, $wgMemc, $wgDBname, $wgScriptPath;
     global $wgRequest, $wgSitename, $wgLanguageCode;
     global $wgScript;
     $fname = "wfSpecialEmailLink";
     if ($wgRequest->getVal('fromajax')) {
         $wgOut->setArticleBodyOnly(true);
     }
     $this->setHeaders();
     $me = Title::makeTitle(NS_SPECIAL, "EmailLink");
     $action = $me->getFullURL();
     $fc = new FancyCaptcha();
     $pass_captcha = true;
     $name = $from = $r1 = $r2 = $r3 = $m = "";
     if ($wgRequest->wasPosted()) {
         $pass_captcha = $fc->passCaptcha();
         $email = $wgRequest->getVal("email");
         $name = $wgRequest->getVal("name");
         $recipient1 = $wgRequest->getVal('recipient1');
         $recipient2 = $wgRequest->getVal('recipient2');
         $recipient3 = $wgRequest->getVal('recipient3');
         if (preg_match("@kittens683\\@aol.com@", $recipient1) || preg_match("@kittens683\\@aol.com@", $recipient2) || preg_match("@kittens683\\@aol.com@", $recipient3)) {
             return;
         }
         $message = $wgRequest->getVal('message');
     }
     if (!$wgRequest->wasPosted() || !$pass_captcha) {
         if ($wgUser->getID() > 0 && !$wgUser->canSendEmail()) {
             $userEmail = $wgUser->getEmail();
             // If there is no verification time stamp and no email on record, show initial message to have a user input a valid email address
             if (empty($userEmail)) {
                 wfDebug("User can't send.\n");
                 $wgOut->errorpage("mailnologin", "mailnologintext");
             } else {
                 // When user does have an email on record, but has not verified it yet
                 wfDebug("User can't send without verification.\n");
                 $wgOut->errorpage("mailnologin", "mailnotverified");
             }
             return;
         }
         $titleKey = isset($par) ? $par : $wgRequest->getVal('target');
         if ($titleKey == "") {
             $wgOut->addHTML("<br/></br><font color=red>" . wfMsg('error-no-title') . "</font>");
             return;
         }
         $titleObj = Title::newFromURL($titleKey);
         if (!$titleObj) {
             $titleObj = Title::newFromURL(urldecode($titleKey));
         }
         if (!$titleObj || $titleObj->getArticleID() < 0) {
             $wgOut->addHTML("<br/></br><font color=red>" . wfMsg('error-article-not-found') . "</font>");
             return;
         } else {
             $titleKey = $titleObj->getDBKey();
         }
         $articleObj = new Article($titleObj);
         $subject = $titleObj->getText();
         $titleText = $titleObj->getText();
         if (WikihowArticleEditor::articleIsWikiHow($articleObj)) {
             $subject = wfMsg('howto', $subject);
             $titleText = wfMsg('howto', $titleText);
         }
         $subject = wfMsg('wikihow-article-subject', $subject);
         if ($titleObj->getText() == wfMsg('mainpage')) {
             $subject = wfMsg('wikihow-article-subject-main-page');
         }
         // add the form HTML
         $article_title = wfMsg('article') . ":";
         if ($titleObj->getNamespace() == NS_ARTICLE_REQUEST) {
             $wgOut->addHTML("<br/><br/>" . wfMsg('know-someone-answer-topic-request'));
             $article_title = wfMsg('topic-requested') . ":";
         }
         if ($titleObj->getNamespace() != NS_MAIN && $titleObj->getNamespace() != NS_ARTICLE_REQUEST && $titleObj->getNamespace() != NS_PROJECT) {
             $wgOut->errorPage('emaillink', 'emaillink_invalidpage');
             return;
         }
         if ($titleObj->getText() == "Books For Africa") {
             $message = wfMsg('friend-sends-article-email-africa-body');
         }
         $titleKey = urlencode($titleKey);
         $token = $this->getToken1();
         $wgOut->addHTML("\n<link type='text/css' rel='stylesheet' href='" . wfGetPad('/extensions/wikihow/common/jquery-ui-themes/jquery-ui.css?rev=' . WH_SITEREV) . "' />\n<form id=\"emaillink\" method=\"post\" action=\"{$action}\">\n<input type=\"hidden\" name=\"target\" value=\"{$titleKey}\">\n<input type=\"hidden\" name=\"token\" value=\"{$token}\">\n<table border=\"0\">\n<tr>\n<td valign=\"top\" colspan=\"1\" class='mw-label'>{$article_title}</td>\n<td valign=\"top\" colspan=\"2\">{$titleText}</td>\n</tr>\n");
         if ($wgUser->getID() <= 0) {
             $wgOut->addHTML("\n<tr>\n<td valign=\"top\" colspan=\"1\" class='mw-label'>" . wfMsg('your-name') . ":</td>\n<td valign=\"top\" colspan=\"2\"><input type=text size=\"40\" name=\"name\" value=\"{$name}\" class='input_med'></td>\n</tr>\n<tr>\n<td valign=\"top\" colspan=\"1\" class='mw-label'>" . wfMsg('your-email') . ":</td>\n<td valign=\"top\" colspan=\"2\"><input type=text size=\"40\" name=\"email\" value=\"{$email}\" class='input_med'></td>\n</tr>");
         }
         $wgOut->addHTML("\n<tr>\n<td valign=\"top\" width=\"300px\" colspan=\"1\" rowspan='3' class='mw-label'>" . wfMsg('recipient-emails') . ":</td>\n<td valign=\"top\" colspan=\"2\"><input type=text size=\"40\" name=\"recipient1\" value=\"{$recipient1}\" class='input_med'></td>\n</tr>\n<tr>\n<td valign=\"top\" colspan=\"2\"><input type=text size=\"40\" name=\"recipient2\" value=\"{$recipient2}\" class='input_med'></td>\n</tr>\n<tr>\n<td valign=\"top\" colspan=\"2\"><input type=text size=\"40\" name=\"recipient3\" value=\"{$recipient3}\" class='input_med'></td>\n</tr>\n<!--<tr>\n<td valign=\"top\" colspan=\"1\">" . wfMsg('emailsubject') . ":</td>\n<td valign=\"top\" colspan=\"2\"><input type=text size=\"40\" name=\"subject\" value=\"{$subject}\" class='input_med'></td>\n</tr>-->\n<tr>\n<td colspan=\"1\" valign=\"top\" class='mw-label'>" . wfMsg('emailmessage') . ":</td>\n<td colspan=\"2\"><TEXTAREA rows=\"5\" cols=\"55\" name=\"message\">{$message}</TEXTAREA></td>\n</tr>\n<tr>\n<TD>&nbsp;</TD>\n<TD colspan=\"2\"><br/>\n" . wfMsgWikiHTML('emaillink_captcha') . "\n" . ($pass_captcha ? "" : "<br><br/><font color='red'>Sorry, that phrase was incorrect, try again.</font><br/><br/>") . "\n" . $fc->getForm('') . "\n</TD>\n</tr>\n<tr>\n<TD>&nbsp;</TD>\n<TD colspan=\"2\"><br/>\n<input type='submit' name=\"wpEmaiLinkSubmit\" value=\"" . wfMsg('submit') . "\" class=\"button primary\" />\n</td>\n</tr>\n<tr>\n<TD colspan=\"3\">\n<br/><br/>\n" . wfMsg('share-message-three-friends') . "\n</TD>\n</TR>\n\n");
         // do this if the user isn't logged in
         $wgOut->addHTML("</table> </form>");
     } else {
         if ($wgUser->pingLimiter('emailfriend')) {
             $wgOut->rateLimited();
             wfProfileOut("{$fname}-checks");
             wfProfileOut($fname);
             return false;
         }
         $usertoken = $wgRequest->getVal('token');
         $token1 = $this->getToken1();
         $token2 = $this->getToken2();
         if ($usertoken != $token1 && $usertoken != $token2) {
             $this->reject();
             echo "token {$usertoken} {$token1} {$token2}\n";
             exit;
             return;
         }
         // check referrer
         $good_referer = Title::makeTitle(NS_SPECIAL, "EmailLink")->getFullURL();
         $referer = $_SERVER["HTTP_REFERER"];
         if (strpos($refer, $good_referer) != 0) {
             $this->reject();
             echo "referrer bad\n";
             exit;
         }
         // this is a post, accept the POST data and create the Request article
         $recipient1 = $_POST['recipient1'];
         $recipient2 = $_POST['recipient2'];
         $recipient3 = $_POST['recipient3'];
         $titleKey = $_POST['target'];
         $message = $_POST['message'];
         if ($titleKey == "Books-For-Africa") {
             $titleKey = "wikiHow:" . $titleKey;
         }
         $titleKey = urldecode($titleKey);
         $titleObj = Title::newFromDBKey($titleKey);
         if ($titleObj->getArticleID() <= 0) {
             $this->reject();
             echo "no article id\n";
             exit;
         }
         $dbkey = $titleObj->getDBKey();
         $articleObj = new Article($titleObj);
         $subject = $titleObj->getText();
         $how_to = $subject;
         if (WikihowArticleEditor::articleIsWikiHow($articleObj)) {
             $subject = wfMsg("howto", $subject);
         }
         $how_to = $subject;
         if ($titleObj->getNamespace() == NS_ARTICLE_REQUEST) {
             $subject = wfMsg('subject-requested-howto') . ": " . wfMsg("howto", $subject);
         } else {
             if ($titleObj->getNamespace() == NS_PROJECT) {
                 $subject = wfMsg('friend-sends-article-email-africa-subject');
             } else {
                 $subject = wfMsg('wikihow-article-subject', $subject);
             }
         }
         if ($titleObj->getNamespace() != NS_MAIN && $titleObj->getNamespace() != NS_ARTICLE_REQUEST && $titleObj->getNamespace() != NS_PROJECT) {
             $wgOut->errorPage('emaillink', 'emaillink_invalidpage');
             return;
         }
         // for the body of the email
         $titleText = $titleObj->getText();
         if ($titleText != wfMsg('mainpage')) {
             $summary = Article::getSection($articleObj->getContent(true), 0);
             // trip out all MW and HTML tags
             $summary = ereg_replace("<.*>", "", $summary);
             $summary = ereg_replace("\\[\\[.*\\]\\]", "", $summary);
             $summary = ereg_replace("\\{\\{.*\\}\\}", "", $summary);
         }
         $url = $titleObj->getFullURL();
         $from_name = "";
         $validEmail = "";
         if ($wgUser->getID() > 0) {
             $from_name = $wgUser->getName();
             $real_name = $wgUser->getRealName();
             if ($real_name != "") {
                 $from_name = $real_name;
             }
             $email = $wgUser->getEmail();
             if ($email != "") {
                 $validEmail = $email;
                 $from_name .= "<{$email}>";
             } else {
                 $from_name .= "<*****@*****.**>";
             }
         } else {
             $email = $wgRequest->getVal("email");
             $name = $wgRequest->getVal("name");
             if ($email == "") {
                 $email = "*****@*****.**";
             } else {
                 $validEmail = $email;
             }
             $from_name = "{$name} <{$email}>";
         }
         if (strpos($email, "\n") !== false || strpos($recipient1, "\n") !== false || strpos($recipient2, "\n") !== false || strpos($recipient3, "\n") !== false || strpos($title, "\n") !== false) {
             echo "reciep\n";
             exit;
             $this->reject();
             return;
         }
         $r_array = array();
         $num_recipients = 0;
         if ($recipient1 != "") {
             $num_recipients++;
             $x = split(";", $recipient1);
             $r_array[] = $x[0];
         }
         if ($recipient2 != "") {
             $num_recipients++;
             $x = split(";", $recipient2);
             $r_array[] = $x[0];
         }
         if ($recipient3 != "") {
             $num_recipients++;
             $x = split(";", $recipient3);
             $r_array[] = $x[0];
         }
         if ($titleObj->getNamespace() == NS_PROJECT) {
             $r_array[] = '*****@*****.**';
         }
         if ($validEmail != "" && !in_array($validEmail, $r_array)) {
             $num_recipients++;
             $r_array[] = $validEmail;
         }
         if ($titleObj->getNamespace() == NS_ARTICLE_REQUEST) {
             $body = "{$message}\n\n----------------\n\n\t" . wfMsg('article-request-email', $how_to, "http://www.wikihow.com/index.php?title2={$dbkey}&action=easy&requested={$dbkey}", "http://www.wikihow.com/Request:{$dbkey}", "http://www.wikihow.com/" . wfMsg('writers-guide-url'), "http://www.wikihow.com/" . wfMsg('about-wikihow-url') . "");
         } else {
             if ($titleObj->getText() == wfMsg('mainpage')) {
                 $body = "{$message}\n\n----------------\n\n\t" . wfMsg('friend-sends-article-email-main-page') . "\n\n\t";
             } else {
                 if ($titleObj->getNamespace() == NS_PROJECT) {
                     $body = "{$message}";
                 } else {
                     $body = "{$message}\n\n----------------\n\n" . wfMsg('friend-sends-article-email', $how_to, $summary, $url) . "\n\n\t";
                 }
             }
         }
         $from = new MailAddress($email);
         foreach ($r_array as $address) {
             $address = preg_replace("@,.*@", "", $address);
             $to = new MailAddress($address);
             $sbody = $body;
             if ($address == $validEmail) {
                 $sbody = wfMsg('copy-email-from-yourself') . "\n\n" . $sbody;
             }
             if (!userMailer($to, $from, $subject, $sbody, false)) {
                 //echo "got an en error\n";
             }
         }
         SiteStatsUpdate::addLinksEmailed($num_recipients);
         $this->thanks();
     }
 }
Пример #8
0
 /**
  * Does the per-user customizations to a notification e-mail (name,
  * timestamp in proper timezone, etc) and sends it out.
  * Returns true if the mail was sent successfully.
  *
  * @param User $watchingUser
  * @param object $mail
  * @return bool
  * @private
  */
 function composeAndSendPersonalisedMail($watchingUser)
 {
     global $wgLang;
     // From the PHP manual:
     //     Note:  The to parameter cannot be an address in the form of "Something <*****@*****.**>".
     //     The mail command will not parse this properly while talking with the MTA.
     $to = new MailAddress($watchingUser);
     $body = str_replace('$WATCHINGUSERNAME', $watchingUser->getName(), $this->body);
     $timecorrection = $watchingUser->getOption('timecorrection');
     # $PAGEEDITDATE is the time and date of the page change
     # expressed in terms of individual local time of the notification
     # recipient, i.e. watching user
     $body = str_replace('$PAGEEDITDATE', $wgLang->timeanddate($this->timestamp, true, false, $timecorrection), $body);
     $error = userMailer($to, $this->from, $this->subject, $body, $this->replyto);
     return $error == '';
 }
 function doSubmit()
 {
     global $wgOut, $wgUser;
     $to = new MailAddress($this->target);
     $from = new MailAddress($wgUser);
     $subject = $this->subject;
     if (wfRunHooks('EmailUser', array(&$to, &$from, &$subject, &$this->text))) {
         $mailResult = userMailer($to, $from, $subject, $this->text);
         if (WikiError::isError($mailResult)) {
             $wgOut->addHTML(wfMsg("usermailererror") . $mailResult);
         } else {
             // if the user requested a copy of this mail, do this now,
             // unless they are emailing themselves, in which case one copy of the message is sufficient.
             if ($this->cc_me && $to != $from) {
                 $cc_subject = wfMsg('emailccsubject', $this->target->getName(), $subject);
                 if (wfRunHooks('EmailUser', array(&$from, &$from, &$cc_subject, &$this->text))) {
                     $ccResult = userMailer($from, $from, $cc_subject, $this->text);
                     if (WikiError::isError($ccResult)) {
                         // At this stage, the user's CC mail has failed, but their
                         // original mail has succeeded. It's unlikely, but still, what to do?
                         // We can either show them an error, or we can say everything was fine,
                         // or we can say we sort of failed AND sort of succeeded. Of these options,
                         // simply saying there was an error is probably best.
                         $wgOut->addHTML(wfMsg("usermailererror") . $ccResult);
                         return;
                     }
                 }
             }
             $titleObj = SpecialPage::getTitleFor("Emailuser");
             $encTarget = wfUrlencode($this->target->getName());
             $wgOut->redirect($titleObj->getFullURL("target={$encTarget}&action=success"));
             wfRunHooks('EmailUserComplete', array($to, $from, $subject, $this->text));
         }
     }
 }
Пример #10
0
 function doSubmit()
 {
     global $wgOut, $wgUser;
     $to = array();
     $addrs = preg_split('/[,;]/', $this->target);
     $err = false;
     for ($i = 0; $i < count($addrs); $i++) {
         $addr = trim($addrs[$i]);
         $u = null;
         if ($addr) {
             $u = User::newFromName($addr);
         }
         if (is_null($u) || $u->getID() == 0) {
             if (strpos($addr, '@') > 0) {
                 $to[] = $addr;
             }
         } else {
             if (!$u->canReceiveEmail()) {
                 $err = true;
                 $wgOut->addHTML('<div class="error">' . wfMsg("noemailtext", $addr) . '</div>');
             } else {
                 $to[] = $u->getEmail();
             }
         }
     }
     if ($err || count($to) == 0) {
         // have we already displayed the probable reason?
         $this->showForm($err ? '' : "Missing or invalid recipient email address / user name");
         return;
     }
     $dest = new MailAddress(implode(", ", $to));
     // hack to pass in multiple addresses to userMailer
     $from = new MailAddress($wgUser);
     $subject = $this->subject;
     $text = $this->text;
     if (wfRunHooks('Email', array(&$dest, &$from, &$subject, &$text))) {
         $mailResult = userMailer($dest, $from, $subject, $text);
         $destString = $dest->toString();
         wfDebug("SpecialEmail email sent to: {$destString}\n");
         if (WikiError::isError($mailResult)) {
             $err = true;
             $wgOut->addHTML(wfMsg("usermailererror") . $mailResult);
         } else {
             $titleObj = Title::makeTitle(NS_SPECIAL, "Email");
             $encTarget = wfUrlencode($this->returnTo);
             $wgOut->redirect($titleObj->getFullURL("returnto={$encTarget}&action=success"));
             wfRunHooks('EmailComplete', array($dest, $from, $subject, $text));
         }
     }
 }
Пример #11
0
 function run()
 {
     userMailer($this->params['to'], $this->params['from'], $this->params['subj'], $this->params['body'], $this->params['replyto']);
     return true;
 }
 function doSubmit()
 {
     global $wgOut, $wgUser, $wgLang, $wgOutputEncoding;
     $from = wfQuotedPrintable($wgUser->getName()) . " <" . $wgUser->getEmail() . ">";
     $subject = wfQuotedPrintable($this->subject);
     if (wfRunHooks('EmailUser', array(&$this->mAddress, &$from, &$subject, &$this->text))) {
         $mailResult = userMailer($this->mAddress, $from, $subject, $this->text);
         if (WikiError::isError($mailResult)) {
             $wgOut->addHTML(wfMsg("usermailererror") . $mailResult);
         } else {
             $titleObj = Title::makeTitle(NS_SPECIAL, "Emailuser");
             $encTarget = wfUrlencode($this->target);
             $wgOut->redirect($titleObj->getFullURL("target={$encTarget}&action=success"));
             wfRunHooks('EmailUserComplete', array($this->mAddress, $from, $subject, $this->text));
         }
     }
 }
 function doSubmit()
 {
     global $wgOut, $wgContactSender, $wgContactSenderName;
     #TODO: check captcha
     $fname = 'EmailContactForm::doSubmit';
     wfDebug("{$fname}: start\n");
     $to = new MailAddress($this->target);
     $from = new MailAddress($wgContactSender, $wgContactSenderName);
     $replyto = $this->fromaddress ? new MailAddress($this->fromaddress, $this->fromname) : NULL;
     $subject = trim($this->subject);
     if ($subject === "") {
         $subject = wfMsgForContent("contactpage-defsubject");
     }
     if ($this->fromname !== "") {
         $subject = wfMsgForContent("contactpage-subject-and-sender", $subject, $this->fromname);
     }
     if (wfRunHooks('ContactForm', array(&$to, &$replyto, &$subject, &$this->text))) {
         wfDebug("{$fname}: sending mail from " . $from->toString() . " to " . $to->toString() . " replyto " . ($replyto == null ? '-/-' : $replyto->toString()) . "\n");
         #HACK: in MW 1.9, replyto must be a string, in MW 1.0, it must be an object!
         $ver = preg_replace('![^\\d._+]!', '', $GLOBALS['wgVersion']);
         $replyaddr = $replyto == null ? NULL : version_compare($ver, '1.10', '<') ? $replyto->toString() : $replyto;
         $mailResult = userMailer($to, $from, $subject, $this->text, $replyaddr);
         if (WikiError::isError($mailResult)) {
             $wgOut->addHTML(wfMsg("usermailererror") . $mailResult);
         } else {
             // if the user requested a copy of this mail, do this now,
             // unless they are emailing themselves, in which case one copy of the message is sufficient.
             if ($this->cc_me && $replyto) {
                 $cc_subject = wfMsg('emailccsubject', $this->target->getName(), $subject);
                 if (wfRunHooks('ContactForm', array(&$from, &$replyto, &$cc_subject, &$this->text))) {
                     wfDebug("{$fname}: sending cc mail from " . $from->toString() . " to " . $replyto->toString() . "\n");
                     $ccResult = userMailer($replyto, $from, $cc_subject, $this->text);
                     if (WikiError::isError($ccResult)) {
                         // At this stage, the user's CC mail has failed, but their
                         // original mail has succeeded. It's unlikely, but still, what to do?
                         // We can either show them an error, or we can say everything was fine,
                         // or we can say we sort of failed AND sort of succeeded. Of these options,
                         // simply saying there was an error is probably best.
                         $wgOut->addHTML(wfMsg("usermailererror") . $ccResult);
                         return;
                     }
                 }
             }
             wfDebug("{$fname}: success\n");
             $titleObj = SpecialPage::getTitleFor("Contact");
             $wgOut->redirect($titleObj->getFullURL("action=success"));
             wfRunHooks('ContactFromComplete', array($to, $replyto, $subject, $this->text));
         }
     }
     wfDebug("{$fname}: end\n");
 }