private function contact() { global $wgEmergencyContact; $this->getOutput()->addModules('skins.settlein.special.contact'); $this->getOutput()->setPageTitle('Contact Us | SettleIn'); $data = array(); if ($this->getRequest()->wasPosted()) { $name = $this->getRequest()->getVal('name'); $email = $this->getRequest()->getVal('email'); $message = $this->getRequest()->getVal('message'); $reason = $this->getRequest()->getVal('reason'); $reason = wfMessage('settlein-skin-project-page-contact-field-reason-value-' . ((int) $reason + 1))->plain(); $to = new MailAddress($wgEmergencyContact); $from = new MailAddress($email, $name); $subject = "New request from SettleIn website"; $body = "Reason: " . $reason . "\n\n" . $message; UserMailer::send($to, $from, $subject, $body); $this->getOutput()->redirect($this->getFullTitle()->getFullURL('success=yes')); return false; } else { if ($this->getRequest()->getVal('success')) { $html = Views::forge('contactpost_new', $data); } else { $html = Views::forge('contact_new', $data); } } $this->getOutput()->addHTML($html); }
public function execute($subpage) { global $wgRequest, $wgForceSendgridEmail, $wgForceSchwartzEmail; wfProfileIn(__METHOD__); // Don't allow just anybody to use this if ($this->mChallengeToken != $wgRequest->getVal('challenge')) { header("Status: 400"); header("Content-type: text/plain"); print "Challenge incorrect"; wfProfileOut(__METHOD__); exit; } // Make sure we get an email address $this->mAccount = $wgRequest->getVal('account'); if (!$this->mAccount) { header("Status: 400"); header("Content-type: text/plain"); print "Parameter 'account' required"; wfProfileOut(__METHOD__); exit; } # These two both have defaults $this->mText = $wgRequest->getVal('text', $this->mText); $this->mConfirmToken = $wgRequest->getVal('token', $this->mConfirmToken); $wgForceSendgridEmail = $wgRequest->getVal('force') == 'sendgrid'; $wgForceSchwartzEmail = $wgRequest->getVal('force') == 'schwartz'; UserMailer::send(new MailAddress($this->mAccount), new MailAddress('*****@*****.**'), "EmailTest - End to end test", $this->mConfirmToken . "\n" . $this->mText, null, null, "emailtest"); header("Status: 200"); header("Content-type: text/plain"); print $this->mConfirmToken; wfProfileOut(__METHOD__); exit; }
/** * Send a Notification to a user by email * * @param $user User to notify. * @param $event EchoEvent to notify about. * @return bool */ public static function notifyWithEmail($user, $event) { // No valid email address or email notification if (!$user->isEmailConfirmed() || $user->getOption('echo-email-frequency') < 0) { return false; } // Final check on whether to send email for this user & event if (!wfRunHooks('EchoAbortEmailNotification', array($user, $event))) { return false; } // See if the user wants to receive emails for this category or the user is eligible to receive this email if (in_array($event->getType(), EchoNotificationController::getUserEnabledEvents($user, 'email'))) { global $wgEchoEnableEmailBatch, $wgEchoNotifications, $wgNotificationSender, $wgNotificationSenderName, $wgNotificationReplyName, $wgEchoBundleEmailInterval; $priority = EchoNotificationController::getNotificationPriority($event->getType()); $bundleString = $bundleHash = ''; // We should have bundling for email digest as long as either web or email bundling is on, for example, talk page // email bundling is off, but if a user decides to receive email digest, we should bundle those messages if (!empty($wgEchoNotifications[$event->getType()]['bundle']['web']) || !empty($wgEchoNotifications[$event->getType()]['bundle']['email'])) { wfRunHooks('EchoGetBundleRules', array($event, &$bundleString)); } if ($bundleString) { $bundleHash = md5($bundleString); } MWEchoEventLogging::logSchemaEcho($user, $event, 'email'); // email digest notification ( weekly or daily ) if ($wgEchoEnableEmailBatch && $user->getOption('echo-email-frequency') > 0) { // always create a unique event hash for those events don't support bundling // this is mainly for group by if (!$bundleHash) { $bundleHash = md5($event->getType() . '-' . $event->getId()); } MWEchoEmailBatch::addToQueue($user->getId(), $event->getId(), $priority, $bundleHash); return true; } $addedToQueue = false; // only send bundle email if email bundling is on if ($wgEchoBundleEmailInterval && $bundleHash && !empty($wgEchoNotifications[$event->getType()]['bundle']['email'])) { $bundler = MWEchoEmailBundler::newFromUserHash($user, $bundleHash); if ($bundler) { $addedToQueue = $bundler->addToEmailBatch($event->getId(), $priority); } } // send single notification if the email wasn't added to queue for bundling if (!$addedToQueue) { // instant email notification $toAddress = new MailAddress($user); $fromAddress = new MailAddress($wgNotificationSender, $wgNotificationSenderName); $replyAddress = new MailAddress($wgNotificationSender, $wgNotificationReplyName); // Since we are sending a single email, should set the bundle hash to null // if it is set with a value from somewhere else $event->setBundleHash(null); $email = EchoNotificationController::formatNotification($event, $user, 'email', 'email'); $subject = $email['subject']; $body = $email['body']; UserMailer::send($toAddress, $fromAddress, $subject, $body, $replyAddress); MWEchoEventLogging::logSchemaEchoMail($user, 'single'); } } return true; }
/** * Quickie wrapper function for sending out an email as properly rendered * HTML instead of plaintext. * * The functions in this class that call this function used to use * User::sendMail(), but it was causing the mentioned bug, hence why this * function had to be introduced. * * @see https://bugzilla.wikimedia.org/show_bug.cgi?id=68045 * * @param User $string User (object) whom to send an email * @param string $subject Email subject * @param $string $body Email contents (HTML) * @return Status object */ public function sendMail($user, $subject, $body) { global $wgPasswordSender; $sender = new MailAddress($wgPasswordSender, wfMessage('emailsender')->inContentLanguage()->text()); $to = new MailAddress($user); return UserMailer::send($to, $sender, $subject, $body, null, 'text/html; charset=UTF-8'); }
public function execute() { $params = $this->extractRequestParams(); // Validation if (!User::isValidEmailAddr($params['email'])) { $this->dieUsage('The email address does not appear to be valid', 'invalidemail'); } // Verification code $code = md5('EmailCapture' . time() . $params['email'] . $params['info']); // Insert $dbw = wfGetDB(DB_MASTER); $dbw->insert('email_capture', array('ec_email' => $params['email'], 'ec_info' => isset($params['info']) ? $params['info'] : null, 'ec_code' => $code), __METHOD__, array('IGNORE')); if ($dbw->affectedRows()) { // Send auto-response global $wgEmailCaptureSendAutoResponse, $wgEmailCaptureAutoResponse; $title = SpecialPage::getTitleFor('EmailCapture'); $link = $title->getCanonicalURL(); $fullLink = $title->getCanonicalURL(array('verify' => $code)); if ($wgEmailCaptureSendAutoResponse) { UserMailer::send(new MailAddress($params['email']), new MailAddress($wgEmailCaptureAutoResponse['from'], $wgEmailCaptureAutoResponse['from-name']), wfMsg($wgEmailCaptureAutoResponse['subject-msg']), wfMsg($wgEmailCaptureAutoResponse['body-msg'], $fullLink, $link, $code), $wgEmailCaptureAutoResponse['reply-to'], $wgEmailCaptureAutoResponse['content-type']); } $r = array('result' => 'Success'); } else { $r = array('result' => 'Failure', 'message' => 'Duplicate email address'); } $this->getResult()->addValue(null, $this->getModuleName(), $r); }
/** * Send email to external addresses */ private function sendExternalMails() { global $wgNewUserNotifEmailTargets, $wgSitename; foreach ($wgNewUserNotifEmailTargets as $target) { UserMailer::send(new MailAddress($target), new MailAddress($this->sender), $this->makeSubject($target, $this->user), $this->makeMessage($target, $this->user)); } }
function sendEmail(&$u, &$content) { global $wgServer; wfLoadExtensionMessages('ThumbsEmailNotifications'); $email = $u->getEmail(); $userText = $u->getName(); $semi_rand = md5(time()); $mime_boundary = "==MULTIPART_BOUNDARY_{$semi_rand}"; $mime_boundary_header = chr(34) . $mime_boundary . chr(34); $userPageLink = self::getUserPageLink($userText); $html_text = wfMsg('tn_email_html', wfGetPad(''), $userPageLink, $content); $plain_text = wfMsg('tn_email_plain', $userText, $u->getTalkPage()->getFullURL()); $body = "This is a multi-part message in MIME format.\n\n--{$mime_boundary}\nContent-Type: text/plain; charset=us-ascii\nContent-Transfer-Encoding: 7bit\n\n{$plain_text}\n\n--{$mime_boundary}\nContent-Type: text/html; charset=us-ascii\nContent-Transfer-Encoding: 7bit\n\n{$html_text}"; $from = new MailAddress(wfMsg('aen_from')); $subject = "Congratulations! You just got a thumbs up"; $isDev = false; if (strpos($_SERVER['HOSTNAME'], "wikidiy.com") !== false || strpos($wgServer, "wikidiy.com") !== false) { wfDebug("AuthorEmailNotification in dev not notifying: TO: " . $userText . ",FROM: {$from_name}\n"); $isDev = true; $subject = "[FROM DEV] {$subject}"; } if (!$isDev) { $to = new MailAddress($email); UserMailer::send($to, $from, $subject, $body, null, "multipart/alternative;\n" . " boundary=" . $mime_boundary_header); } // send one to our test email account for debugging /* $to = new MailAddress ('*****@*****.**'); UserMailer::send($to, $from, $subject, $body, null, "multipart/alternative;\n" . " boundary=" . $mime_boundary_header) ; */ return true; }
/** * Run a SMW_NMSendMailJob job * @return boolean success */ function run() { wfDebug(__METHOD__); wfProfileIn(__METHOD__); UserMailer::send($this->params['to'], $this->params['from'], $this->params['subj'], $this->params['body'], $this->params['replyto']); wfProfileOut(__METHOD__); return true; }
function sendEmail() { $from = new MailAddress("*****@*****.**"); $to = new MailAddress("*****@*****.**"); $body = "Test sendgrid email"; $headers = array( "X-Msg-Category" => "Test" ); $subject = "This is a sendgrid test"; UserMailer::send($to, $from, $subject, $body); }
public function execute() { $fb = $this->getMain()->getVal('feedback'); $user = $this->getUser(); $subject = "用户bug反馈"; $body = json_decode($fb); if ($user != '') { if ($body->note != '') { $trueSubject = $user->getName() . ":" . $body->note; } else { $trueSubject = $user->getName() . ":" . $body->note; } } else { if ($body->note != '') { $trueSubject = $body->note; } else { $trueSubject = $subject; } } $fs = wfGetFS(FS_OSS); $time = microtime(); $id = HuijiFunctions::getTradeNo('FB'); $fs->put("Feedback/{$id}.html", $body->html); $data = str_replace('data:image/png;base64,', '', $body->img); $data = str_replace(' ', '+', $data); $data = base64_decode($data); $source_img = imagecreatefromstring($data); imagepng($source_img, "/tmp/{$id}.png", 3); $fs->put("Feedback/{$id}.png", file_get_contents("/tmp/{$id}.png")); imagedestroy($source_img); $trueBody = $this->getSection('Issue'); $trueBody .= $body->note; $trueBody .= $this->getSection('Cookie'); foreach ($_COOKIE as $key => $value) { $trueBody .= $key . ":" . $value . ";" . PHP_EOL; } $trueBody .= $this->getSection('URL'); $trueBody .= $body->url; $trueBody .= $this->getSection('源代码'); $trueBody .= "http://fs.huijiwiki.com/Feedback/{$id}.html"; $trueBody .= $this->getSection('Agent'); foreach ($body->browser as $key => $value) { if (is_array($value)) { $trueBody .= $key . ":" . implode(", ", $value) . ";" . PHP_EOL; } else { $trueBody .= $key . ":" . $value . ";" . PHP_EOL; } } $trueBody .= $this->getSection('来源'); $trueBody .= $body->referer; $trueBody .= $this->getSection('分辨率'); $trueBody .= $body->w . "X" . $body->h; $trueBody .= $this->getSection('截图'); $trueBody .= "http://fs.huijiwiki.com/Feedback/{$id}.png"; $res = UserMailer::send(new MailAddress('*****@*****.**', 'trello', 'trello'), new MailAddress("*****@*****.**"), $trueSubject, $trueBody); $this->getResult()->addValue(null, $this->getModuleName(), $res); }
function sendMessage(\PageAttachment\User\User $user, $subject, $message) { global $wgNoReplyAddress; global $wgPasswordSender; $to = new \MailAddress($user->getEmailAddress()); $from = new \MailAddress($wgPasswordSender); $replyTo = new \MailAddress($wgNoReplyAddress); \UserMailer::send($to, $from, $subject, $message, $replyTo); }
/** * Send mail using a PEAR mailer * * @param UserMailer $mailer * @param string $dest * @param string $headers * @param string $body * * @return Status */ protected static function sendWithPear($mailer, $dest, $headers, $body) { $mailResult = $mailer->send($dest, $headers, $body); # Based on the result return an error string, if (PEAR::isError($mailResult)) { wfDebug("PEAR::Mail failed: " . $mailResult->getMessage() . "\n"); return Status::newFatal('pear-mail-error', $mailResult->getMessage()); } else { return Status::newGood(); } }
function check_existence_of_spamfile($email) { global $wgSitename, $wgCityId; $articles = getWikiArticles(); if (!empty($articles)) { ob_start(); echo $wgSitename, "\n"; print_r($articles); $body = ob_get_clean(); UserMailer::send(new MailAddress($email), new MailAddress($email), 'Spam list related pages in NS=8 on ' . $wgSitename . ' - ' . $wgCityId, $body); } }
/** * Notifies a single user of the changes made to properties in a single edit. * * @since 0.1 * * @param SWLGroup $group * @param User $user * @param SWLChangeSet $changeSet * @param boolean $describeChanges * * @return Status */ public static function notifyUser(SWLGroup $group, User $user, SWLChangeSet $changeSet, $describeChanges) { global $wgLang, $wgPasswordSender, $wgPasswordSenderName; $emailText = wfMsgExt('swl-email-propschanged-long', 'parse', $GLOBALS['wgSitename'], $changeSet->getEdit()->getUser()->getName(), SpecialPage::getTitleFor('SemanticWatchlist')->getFullURL(), $wgLang->time($changeSet->getEdit()->getTime()), $wgLang->date($changeSet->getEdit()->getTime())); if ($describeChanges) { $emailText .= '<h3> ' . wfMsgExt('swl-email-changes', 'parse', $changeSet->getEdit()->getTitle()->getFullText(), $changeSet->getEdit()->getTitle()->getFullURL()) . ' </h3>'; $emailText .= self::getChangeListHTML($changeSet, $group); } $title = wfMsgReal('swl-email-propschanged', array($changeSet->getEdit()->getTitle()->getFullText()), true, $user->getOption('language')); wfRunHooks('SWLBeforeEmailNotify', array($group, $user, $changeSet, $describeChanges, &$title, &$emailText)); return UserMailer::send(new MailAddress($user), new MailAddress($wgPasswordSender, $wgPasswordSenderName), $title, $emailText, null, 'text/html; charset=ISO-8859-1'); }
private function sendNotification() { global $wgFlowerUrl; $subject = "ImageReview deletion failed #{$this->taskId}"; $body = "{$wgFlowerUrl}/task/{$this->taskId}"; $recipients = [new \MailAddress('*****@*****.**'), new \MailAddress('*****@*****.**'), new \MailAddress('*****@*****.**')]; $from = $recipients[0]; foreach ($recipients as $recipient) { \UserMailer::send($recipient, $from, $subject, $body); } WikiaLogger::instance()->error("ImageReviewLog", ['method' => __METHOD__, 'message' => "Task #{$this->taskId} deleting images did not succeed. Please check.", 'taskId' => $this->taskId, 'taskUrl' => $body]); }
function sendComeBackMail($user, $batch) { $body = wfMsg('Come-on-back-email' . $batch, $wgServer, $user->getName(), $wgServer . '/' . preg_replace('/ /', '-', $user->getTalkPage()), $user->getName()); $from = new MailAddress("*****@*****.**"); $to = new MailAddress($user->getEmail()); $content_type = "text/html; charset={$wgOutputEncoding}"; $subject = "Can you help out with a few things on wikiHow?"; if ($batch == 3) { $subject = "Can you try out wikiHow’s new and improved Quality Guardian tool?"; } UserMailer::send($to, $from, $subject, $body, false, $content_type); }
/** * The main method, creates */ public function execute() { foreach ($this->recipients as $recipient) { echo "Sending to: {$recipient}... "; $to = new MailAddress($recipient); $sent = UserMailer::send($to, $this->from, $this->subject, $this->body, $this->replyTo, null); if ($sent) { echo "done!\n"; } else { echo "failed!\n"; } } return null; }
/** * * @param User $userFrom User creating the code * @param string $to Email address to send to * @param string $message The user message, to send along the code * @param mixed $language The language to translate generic message * @return boolean True = ok, false = error while sending */ public function sendCode($userFrom, $to, $message, $language) { $to = new MailAddress($to); $from = new MailAddress($userFrom); $userFromName = $userFrom->getName(); $subject = wfMessage('wpm-invitation-subj', $userFromName)->inLanguage($language)->text(); $body = wfMessage('wpm-invitation-body', $userFromName, $message, $this->wpi_code, 'wpi-' . $this->getCategory()->getDescription())->inLanguage($language)->text(); $body .= wfMessage('wp-mail-footer')->inLanguage($language)->text(); try { UserMailer::send($to, $from, $subject, $body); } catch (Exception $e) { wfDebugLog('wikiplaces', 'WpInvitation::sendCode: ERROR SENDING EMAIL from ' . $from . '", to ' . $to . ', code ' . $this->wpi_code); return false; } return true; }
function run() { $status = UserMailer::send($this->params['to'], $this->params['from'], $this->params['subj'], $this->params['body'], $this->params['replyto']); $isOK = $status->isOK(); if ($isOK && $this->params['emailType'] === 'reminder') { $user = User::newFromId($this->params['user']); $reminders = $user->getOption('translate-sandbox-reminders'); $reminders = $reminders ? explode('|', $reminders) : array(); $reminders[] = wfTimestamp(); $user->setOption('translate-sandbox-reminders', implode('|', $reminders)); $reminders = $user->getOption('translate-sandbox-reminders'); $user->setOption('translate-sandbox-reminders', $reminders); $user->saveSettings(); } return $isOK; }
function wfCheckPAD($url, $pad) { global $wgServer, $wgTitle, $wgCookieDomain; if ($wgServer == "http://testers.wikihow.com") { return true; } if (($wgServer == "http://www.wikihow.com" || strpos(wfHostname(), "wikihow.com") !== false) && strpos($pad, "whstatic") === false) { $alerts = new MailAddress("*****@*****.**"); // format of date to correspond to varnish file 04/Dec/2010:07:19:06 -0800 $now = date("d/M/Y:h:i:s O"); $subject = "Not using PAD for thumbnail on " . wfHostname() . " - " . $now; $body = "article {$wgTitle->getFullURL()}\n\n\nUrl: {$url} \n\n \npad {$pad} \n\n\nserver variables " . print_r($_SERVER, true) . "\n\n allheaders: " . print_r(getallheaders(), true) . "\n\n wgserver {$wgServer}\n\ncookie domain {$wgCookieDomain}\n\n Title " . print_r($wgTitle, true) . "\n\nbacktrace: " . strip_tags(wfBacktrace()); UserMailer::send($alerts, $alerts, $subject, $body, $alerts); error_log($body); wfDebug($body); } return true; }
/** * Store the submitted story in the database, and return a page telling the user his story has been submitted. * * @param string $title */ private function saveStory($title) { global $wgRequest, $wgUser; global $egStoryboardEmailSender, $egStoryboardEmailSenderName, $egStoryboardBoardUrl; $dbw = wfGetDB(DB_MASTER); $story = array('story_lang_code' => $wgRequest->getText('lang'), 'story_author_name' => $wgRequest->getText('name'), 'story_author_location' => $wgRequest->getText('location'), 'story_author_occupation' => $wgRequest->getText('occupation'), 'story_author_email' => $wgRequest->getText('email'), 'story_title' => $title, 'story_text' => $wgRequest->getText('storytext'), 'story_created' => $dbw->timestamp(time()), 'story_modified' => $dbw->timestamp(time())); // If the user is logged in, also store his user id. if ($wgUser->isLoggedIn()) { $story['story_author_id'] = $wgUser->getId(); } $dbw->insert('storyboard', $story); $to = new MailAddress($wgRequest->getText('email'), $wgRequest->getText('name')); $from = new MailAddress($egStoryboardEmailSender, $egStoryboardEmailSenderName); $subject = wfMsg('storyboard-emailtitle'); $body = wfMsgExt('storyboard-emailbody', 'parsemag', $title, $egStoryboardBoardUrl); $mailer = new UserMailer(); $mailer->send($to, $from, $subject, $body); }
function UW_GenericEditPage_emailSuggestion ( $category ) { global $wgSuggestCategoryRecipient, $wgEmergencyContact, $wgSitename, $wgUser; $from = new MailAddress ( $wgEmergencyContact ); $to = new MailAddress ( $wgSuggestCategoryRecipient ); $subj = wfMsg ( "gep-emailsubject", $wgSitename, $category ); $body = wfMsg ( "gep-emailbody", $wgUser->getName(), $category, $wgSitename ); // attempt to send the notification $result = UserMailer::send( $to, $from, $subj, $body ); /* send a message back to the client, to let them * know if the suggestion was successfully sent (or not) */ return WikiError::isError ( $result ) ? wfMsg ( 'gep-emailfailure' ) : wfMsg ( 'gep-emailsuccess', $category ); }
function wfSendRequestNotificationEmail($emails) { wfLoadExtensionMessages('RequestTopic'); $from = new MailAddress(wfMsg('suggested_notify_email_from')); $semi_rand = md5(time()); $mime_boundary = "==MULTIPART_BOUNDARY_{$semi_rand}"; $mime_boundary_header = chr(34) . $mime_boundary . chr(34); foreach ($emails as $email => $title) { $html_text = wfMsg('suggested_notify_email_html', wfGetPad(''), $title->getText(), $title->getFullURL(), $title->getDBKey(), $title->getTalkPage()->getFullURL()); $plain_text = wfMsg('suggested_notify_email_plain', $title->getText(), $title->getFullURL(), $title->getDBKey(), $title->getTalkPage()->getFullURL()); $body = "This is a multi-part message in MIME format.\n\n--{$mime_boundary}\nContent-Type: text/plain; charset=us-ascii\nContent-Transfer-Encoding: 7bit\n\n{$plain_text}\n\n--{$mime_boundary}\nContent-Type: text/html; charset=us-ascii\nContent-Transfer-Encoding: 7bit\n\n{$html_text}"; $subject = wfMsg('suggested_notify_email_subject', $title->getText()); if (!$title) { continue; } $to = new MailAddress($email); UserMailer::send($to, $from, $subject, $body, null, "multipart/alternative;\n" . " boundary=" . $mime_boundary_header); } return true; }
public function main() { print "Getting quizzes\n"; try { $gs = new GoogleSpreadsheet(); $gs->login(WH_TREBEK_GOOGLE_LOGIN, WH_TREBEK_GOOGLE_PW); $headers = $gs->getHeaders(WH_QUIZZES_GOOGLE_DOC); self::parseHeaders($headers); $quiz_data = array(); $cols = $gs->getColsWithSpaces(WH_QUIZZES_GOOGLE_DOC, 1, count($headers), 2); if (!empty($cols)) { foreach ($cols as $row) { $question_array = self::makeQuestionArray($row); if ($row[self::$quiz_name] != $last_quiz_name && $last_quiz_name != '') { //new quiz! //let's stash the old one self::saveQuizAsBlob($last_quiz_name, $last_quiz_icon, $quiz_data); $quiz_data = array(); } //add in the question $quiz_data[] = $question_array; //store last quiz name to check on next time $last_quiz_name = $row[self::$quiz_name]; $last_quiz_icon = $row[self::$quiz_icon]; } //save the final quiz self::saveQuizAsBlob($last_quiz_name, $last_quiz_icon, $quiz_data); } } catch (Exception $e) { } //send completion mail $to = new MailAddress('elizabeth@wikihow.com, allie@wikihow.com, scott@wikihow.com'); $from = new MailAddress(WH_TREBEK_GOOGLE_LOGIN); $subject = 'Quizzes processed'; $quizzes = implode(self::$import_array, "\n"); $body = "Your quizzes have completed processing. Get back to work!\n\n" . "Oh, and here they are:\n\n{$quizzes}\n"; UserMailer::send($to, $from, $subject, $body); print "Done.\n"; }
function sendWelcomeUser($user) { global $wgServer, $wgOutputEncoding; if ($user->getID() == 0) { wfDebug("Welcome email:User must be logged in.\n"); return true; } if ($user->getOption('disablemarketingemail') == '1') { wfDebug("Welcome email: Marketing preference not selected.\n"); return true; } if ($user->getEmail() == "") { wfDebug("Welcome email: No email address found.\n"); return true; } $subject = wfMsg('welcome-email-subject'); $from_name = ""; $validEmail = ""; $from_name = wfMsg('welcome-email-fromname'); $to_name = $user->getName(); $to_real_name = $user->getRealName(); if ($to_real_name != "") { $to_name = $real_name; } $username = $to_name; $email = $user->getEmail(); $validEmail = $email; $to_name .= " <{$email}>"; //server,username,talkpage,username $body = wfMsg('welcome-email-body', $wgServer, $username, $wgServer . '/' . preg_replace('/ /', '-', $user->getTalkPage()), $user->getName()); $from = new MailAddress($from_name); $to = new MailAddress($to_name); $content_type = "text/html; charset={$wgOutputEncoding}"; if (!UserMailer::send($to, $from, $subject, $body, false, $content_type)) { wfDebug("Welcome email: got an en error while sending.\n"); } return true; }
function send_mail($email_addresses, $send_title, $send_body, $html = true) { global $wgOutputEncoding, $wgPasswordSender, $wgVersion, $awcsf_css_output, $awcs_forum_config; $from_address = new MailAddress($wgPasswordSender); # do str_replace() instead of html_entity_decode() for security $send_title = self::CleanTitle($send_title); $send_body = self::CleanTitle($send_body); /** @changeVer 2.5.8 older wiki's MailAddress() dont handle objects so split to string and pass that */ foreach ($email_addresses as $email) { $addr = $email->address; $name = $email->name; if ($addr == '') { $addr = $email; $name = ''; } $to_address[] = new MailAddress($addr, $name); } $contentType = $html ? 'text/html; charset=' . $wgOutputEncoding : null; $reply_address = null; wfRunHooks('awcsforum_send_mail', array(&$to_address, &$from_address, &$send_title, &$awcsf_css_output, &$send_body, &$reply_address, &$contentType)); // 2.5.5 if ($html) { global $wgServer; $str_find = array('href="/', 'src="/'); $str_replace = array('href="' . $wgServer . '/', 'src="' . $wgServer . '/'); $awcsf_css_output = str_replace($str_find, $str_replace, $awcsf_css_output); $send_body = str_replace($str_find, $str_replace, $send_body); $send_body = "<html xmlns=\"http://www.w3.org/1999/xhtml\">\n <head>\n {$awcsf_css_output}\n </head>\n <body>{$send_body}</body>\n </html>"; } if (version_compare($wgVersion, '1.14.0', '>=')) { UserMailer::send($to_address, $from_address, $send_title, $send_body, $reply_address, $contentType); } else { // use the copied (below) 1.14 class mw_UserMailer::send($to_address, $from_address, $send_title, $send_body, $reply_address, $contentType); } }
function run($par) { global $wgRequest, $wgEmailMeAddress, $wgOut; if ($wgRequest->wasPosted()) { $from = $wgRequest->getText('from'); $subject = $wgRequest->getText('subject'); $message = $wgRequest->getText('message'); if (!($from && $subject && $message)) { return $this->print_form($this->getTitle(), $subject, $from, $message, wfMsg('emailme-incomplete')); } if (!User::isValidEmailAddr($from)) { return $this->print_form($this->getTitle(), $subject, $from, $message, wfMsg('emailme-invalid-email')); } $mailResult = UserMailer::send(new MailAddress($wgEmailMeAddress), new MailAddress($from), $subject, $message); if (WikiError::isError($mailResult)) { return $this->print_form($this->getTitle(), $subject, $from, $message, 'Sorry: ' . $mailResult->toString()); dvLog("ERROR: EmailMe::run(" . $mailResult->toString() . ") {$from}|{$subject}"); } else { dvLog("EMAIL: {$from} -> {$wgEmailMeAddress} ( {$subject} ) "); return $this->print_success(); } } return $this->print_form($this->getTitle(), str_replace('_', ' ', $par)); }
public function execute($subpage) { global $wgRequest, $wgEnableWikiaDBEmail, $wgEnablePostfixEmail; wfProfileIn(__METHOD__); // Don't allow just anybody to use this if ($this->mChallengeToken != $wgRequest->getVal('challenge')) { header("Status: 400"); header("Content-type: text/plain"); print "Challenge incorrect"; wfProfileOut(__METHOD__); exit; } // Make sure we get an email address $this->mAccount = $wgRequest->getVal('account'); if (!$this->mAccount) { header("Status: 400"); header("Content-type: text/plain"); print "Parameter 'account' required"; wfProfileOut(__METHOD__); exit; } # These two both have defaults $this->mText = $wgRequest->getVal('text', $this->mText); $this->mConfirmToken = $wgRequest->getVal('token', $this->mConfirmToken); # default to whatever mail backend is in config or wikifactory, allow override if ($wgRequest->getVal('force')) { $wgEnableWikiaDBEmail = $wgRequest->getVal('force') == 'wikiadb'; $wgEnablePostfixEmail = $wgRequest->getVal('force') == 'postfix'; } UserMailer::send(new MailAddress($this->mAccount), new MailAddress('*****@*****.**'), "EmailTest - End to end test", $this->mConfirmToken . "\n" . $this->mText, null, null, "emailtest", 1); header("Status: 200"); header("Content-type: text/plain"); print $this->mConfirmToken; wfProfileOut(__METHOD__); exit; }
private function doPost() { global $wgOut, $wgRequest, $wgMemc; $method = $wgRequest->getVal('method'); if ($method == 'by_id') { $new_id = $wgRequest->getInt('new_sysop_id'); if (empty($new_id) || $new_id < 0) { $wgOut->addHTML(Wikia::errorbox("bad input")); return false; } if (!User::whois($new_id)) { $wgOut->addHTML(Wikia::errorbox("no user with that id")); return false; } #$wgOut->addHTML( "text['new_sysop_id']=" . $new_id . "<br/>\n"); // BugId:41817 - if ( 1 == $new_id ) { notify Mix } if (1 == $new_id) { $oTo = $oFrom = new MailAddress('*****@*****.**'); UserMailer::send($oTo, $oFrom, 'BugId:41817 Occurrence Report', sprintf("File: %s\nLine: %s, Date: %s\nOutput: %s", __FILE__, __LINE__, date('Y-m-d H:i:s'), var_export($new_id, true))); } $wgMemc->set(wfMemcKey("last-sysop-id"), $new_id, 86400); $wgOut->addHTML(Wikia::successbox("new value saved")); } elseif ($method == 'by_name') { $new_text = $wgRequest->getText('new_sysop_text'); if (empty($new_text)) { $wgOut->addHTML(Wikia::errorbox("bad input")); return false; } $new_id = User::idFromName($new_text); if (empty($new_id)) { $wgOut->addHTML(Wikia::errorbox("name not found as user")); return false; } #$wgOut->addHTML( "text['new_sysop_text']=[" . $new_text . "]<br/>\n"); // BugId:41817 - if ( 1 == $new_id ) { notify Mix } if (1 == $new_id) { $oTo = $oFrom = new MailAddress('*****@*****.**'); UserMailer::send($oTo, $oFrom, 'BugId:41817 Occurrence Report', sprintf("File: %s\nLine: %s, Date: %s\nOutput: %s", __FILE__, __LINE__, date('Y-m-d H:i:s'), var_export($new_id, true))); } $wgMemc->set(wfMemcKey("last-sysop-id"), $new_id, 86400); $wgOut->addHTML(Wikia::successbox("new value saved")); } elseif ($method == 'clear') { $wgMemc->delete(wfMemcKey("last-sysop-id")); $wgOut->addHTML(Wikia::successbox("cleared")); } else { $wgOut->addHTML("unknown method [{$method}] used to POST<br/>\n"); } }
/** * Send an email notifying the user of the result of their request. * * @param MailAddress $to * @param string $subject * @param string $body * @return Status */ protected function sendNotificationEmail(MailAddress $to, $subject, $body) { global $wgPasswordSender; $from = new MailAddress($wgPasswordSender, wfMessage('emailsender')->inContentLanguage()->text()); return UserMailer::send($to, $from, $subject, $body); }