public function getConfiguredMailer() { if (!$this->mailer_config) { throw new Exception('MailerBlast needs to have the mailer configured.'); } $mlr = new Mailer(); foreach ($this->mailer_config as $k => $v) { switch ($k) { case 'cc': $mlr->addCc($v); break; case 'bcc': $mlr->addBcc($v); break; case 'from': $mlr->setFrom($v); break; case 'replyto': $mlr->setReplyTo($v); break; case 'subject': $mlr->setSubject($v); break; case 'content-type': $mlr->setContentType($v); break; case 'headers': $mlr->headers .= $v; break; default: break; } } return $mlr; }
public function sendMail($project, $submodule, $message) { $projectUids = Common::checkboxStrDecode($project['monitors']); $submoduleUids = Common::checkboxStrDecode($submodule['monitors']); $uids = array_merge($projectUids, $submoduleUids); $monitorDB = new MonitorModelDB(); $monitorsMail = $monitorDB->getData('SELECT email FROM ' . $monitorDB->getTableName() . ' WHERE id in ?', array($uids)); $mail = new Mailer(); $mail->setSubject("{$project['name']}的{$submodule['name']}({$submodule['code']})错误"); $mail->MsgHTML("错误详细:{$message}"); foreach ($monitorsMail as $monitorMail) { $mail->AddAddress($monitorMail['email']); } $mail->Send(); $warningMessageDB = new WarningMessageModelDB(); $warningMessageDB->insert(array('type' => 1, 'message' => "{$project['name']}的{$submodule['name']}({$submodule['code']})错误:{$message}", 'monitors' => Common::checkboxStrEncode($uids), 'create_time' => time())); }
public function process($params) { if (!isset($params[0])) { throw new MException("Mod id not specified."); } $modId = $params[0]; // also select devname and email for mailing updates $sth = $this->getDB()->prepare("SELECT id, name, devname, devemail, version, available\r\n\t\t\t\t\t\tFROM mods\r\n\t\t\t\t\t\tWHERE id = :id"); $sth->bindValue(":id", $modId, PDO::PARAM_INT); $sth->execute(); $modExists = $sth->fetch(PDO::FETCH_ASSOC); if (!empty($modExists)) { // this mod is in the repo if ($modExists["available"] == 0) { // check whether file has been uploaded yet $fileLocation = sprintf('%1$s../downloads/mods/%2$s/%3$d/%2$s.mod.dll', MBASE_PATH, $modExists["name"], $modExists["version"]); if (!file_exists($fileLocation)) { throw new MException(sprintf("Mod %s has no version %d in the repo yet.", $modExists["name"], $modExists["version"])); } else { // file exists on server, nothing to stop us from activating now :) $sth = $this->getDB()->prepare("UPDATE mods\r\n\t\t\t\t\t\t\t\t\tSET available = 1\r\n\t\t\t\t\t\t\t\t\tWHERE id = :id"); $sth->bindValue(":id", $modExists["id"], PDO::PARAM_INT); if ($sth->execute()) { // send mail to developer to notify him of the update $m = new Mailer(new MailAddress("*****@*****.**", sprintf("%s Mod Repo", REPO_NAME))); $m->addRecipient(new MailAddress($modExists["devemail"], $modExists["devname"])); $m->setSubject("Your mod has been added."); $tpl = $m->getMustache()->loadTemplate("mod_activated.mustache"); $m->setBody($tpl->render(array("REPONAME" => REPO_NAME, "REPOURL" => REPO_URL, "DEVNAME" => $modExists["devname"], "MODNAME" => $modExists["name"]))); $m->send(); echo sprintf("Mod %s is now available. Wait for the cache to update.\n", $modExists["name"]); } else { throw new MException("Mot not made available, database error."); } } } else { throw new MException(sprintf("Mod %s is already available.", $modExists["name"])); } } else { // mod is not in the submission queue throw new MException(sprintf("Mod %d does not exist in the submission queue.", $modId)); } }
public function delete($file) { $encodedEntryURI = $this->policy->encodedEntryURI($file); $url = 'http://rs.qiniu.com/delete/' . $encodedEntryURI; $access_token = $this->policy->genAccessToken($url); $HttpReuqst = new Request($url, 'POST'); $HttpReuqst->setHeader('Authorization', 'QBox ' . $access_token); $response = $HttpReuqst->send(); $code = $response->getStatus(); if ($code == 599) { //给七牛发邮件 $body = print_r($response->getRequestHeader(), true) . $response->getBody(); $mail = new Mailer(); $mail->setSubject("服务端操作失败"); $mail->setBody($body); $mail->setTo("*****@*****.**"); $mail->send(); } elseif ($code != 200) { return false; } return true; }
<input name="kamer" type="text"/> </div> <input type="submit" value="<?php echo $taal->msg('versturen'); ?> "/> </fieldset> </form> <?} else{ $mailer = new Mailer(); $mailer->setHTMLCharset("UTF-8"); $mailer->setFrom($_POST['email']); $mailer->setCc($_POST['email']); $mailer->setSubject("adreswijziging"); $mailer->setText("Beste,\n\nIs het mogelijk van de kotadres gegevens van de volgende student aan te passen?\n\n".$_POST['voornaam']." ".$_POST['naam']."\nStudentennummer: ".$_POST['studnummer']."\nKotadres:\n".$_POST['home'].", kamernummer ".$_POST['kamer']."\n\n\n==========\nDeze e-mail werd gegenereerd door het Online Herstelformulier van de Afdeling Huisvesting"); $mailer->send(array("*****@*****.**"));//helpdesk.studadmin@UGent.be ?> <h1><?php echo $taal->msg('adresaanpassen'); ?> </h1> <p><?php echo $taal->msg('adresaanpassen_submitted'); ?> </p> <?} ?> </div> </div>
} $beheerders = Personeel::getBeheerders(); foreach ($beheerders as $personeel) { $mailer = new Mailer(); $mailer->setHTMLCharset("UTF-8"); $mailer->setFrom($from); $homes = $personeel->getHomesLijst(); foreach ($homes as $home) { $id = $home->getId(); if (isset($count[$id]) && ($count[$id] > 0)) { // $personeel is homemanager van een home die een mail moet krijgen over $count[$id] ongeziene formulieren $mailer->setSubject("[Herstelformulieren] ".$count[$id]." ongezien"); $mailer->setText("Beste,\n\nEr zijn sinds gisteren ".$count[$id]." herstelformulieren bijgekomen uit ".$home->getLangeNaam()." die nog bekeken moeten worden. Gelieve hiervoor in te loggen op https://chaos.ugent.be/test_herstelformulier/repair/index.php ."); //$mailer->send(array($personeel->getEmail())); } } }*/ $beheerders = Personeel::getBeheerders(); foreach ($beheerders as $personeel) { $mailer = new Mailer(); $mailer->setHTMLCharset("UTF-8"); $mailer->setFrom($from); $aantal = sizeof(Herstelformulier::getPersoneelList($personeel->getHomeStringLijst(), new Status("ongezien"))); if ($aantal > 0 && $personeel->getMails()) { $mailer->setSubject("[Herstelformulieren] " . $aantal . " ongeziene formulieren"); $mailer->setText("Beste,\n\nEr zijn " . $aantal . " ongeziene herstelformulieren uit de homes waarvoor u verantwoordelijk bent. Gelieve hiervoor in te loggen op https://herstelformulier.ugent.be ."); $mailer->send(array($personeel->getEmail())); } }
// overloop alle herstelformulieren die voldoen aan evaluatiecriteria $list = Herstelformulier::getEvaluationList(); // mail user foreach ($list as $formulier) { $student = $formulier->getStudent(); $ldap = new LdapRepair(); $userinfo = $ldap->getUserInfo($student->getGebruikersnaam()); if (isset($userinfo['homeId'])) { // deze student zit hier nog $mailer = new Mailer(); $mailer->setCc("bert.vandeghinste+herstel@gmail.com,mesuerebart+herstel@gmail.com"); $mailer->setHTMLCharset("UTF-8"); $mailer->setFrom($from); $email_student_subject = $student->getTaal() == "nl" ? $email_student_subject_nl : $email_student_subject_en; $email_student_body = $student->getTaal() == "nl" ? $email_student_body_nl : $email_student_body_en; $mailer->setSubject($email_student_subject); $mailer->setText($email_student_body); //$mailer->send(array($student->getEmail())); } } // doorzenden naar Homemanager als er nieuwe herstelformulieren zijn /*$list = Herstelformulier::getList(0, new Status("ongezien")); $count = array(); foreach ($list as $formulier) { $count[$formulier->getHome()->getId()] = $count[$formulier->getHome()->getId()] + 1; } $beheerders = Personeel::getBeheerders(); foreach ($beheerders as $personeel) { $mailer = new Mailer(); $mailer->setHTMLCharset("UTF-8");
#!/usr/bin/php -q <?php require_once "lib/Misc.inc.php"; require_once "lib/Class.Mailer.inc.php"; $cli_args = arguments($argv); $mai = new Mailer(); try { switch ($cli_args['type']) { case 'simple': default: $mai->setFrom("me", "my@mail"); $mai->setTo("None", "panos"); $mai->setSubject("Μία δοκιμή", "UTF-8"); $mai->body = new Mailer_TextBody("test test"); break; case 'utf': $mai->setFrom("Πάνος", "my@mail"); $mai->setTo("Κανένας", "panos"); $mai->setSubject("Μία δοκιμή", "UTF-8"); $mai->body = new Mailer_TextBody("Δοκιμή κειμένου"); break; case 'alt': $mai->setFrom("Πάνος", "my@mail"); $mai->setTo("Κανένας", "panos"); $mai->setSubject("Μία δοκιμή", "UTF-8"); $mai->body = new Mailer_MultipartAlt(); $mai->body->addPart(new Mailer_TextBody("Δοκιμή κειμένου")); $mai->body->addPart(new Mailer_HtmlBody("<html><body>Δοκιμή <u>κειμένου</u></body></html>")); break; } $mai->PrintMail();
function Send_Mails($dbg = 1, $dry = false) { $dbhandle = A2Billing::DBHandle(); if ($dbg > 2) { echo "Mailer: start\n"; } $sqlTimeFmt = _("YYYY-MM-DD HH24:MI:SS TZ"); // TODO: not only select, but lock mails in 'sending' state. $qry = "SELECT cc_mailings.id AS id, mtype, fromname, fromemail, subject, \n\t\tmessage, defargs, tomail, args, to_char(tstamp,'{$sqlTimeFmt}') AS mdate\n\t\tFROM cc_templatemail, cc_mailings\n\t\tWHERE cc_mailings.tmail_id = cc_templatemail.id\n\t\tAND (state = 1 OR state = 5);"; $res = $dbhandle->Execute($qry); if (!$res) { if ($dbg > 0) { echo "Query Failed: " . $dbhandle->ErrorMsg() . "\n"; } return false; } elseif ($res->EOF) { if ($dbg > 2) { echo "No mails need to be sent.\n"; } return true; } try { while ($row = $res->fetchRow()) { if ($dbg > 2) { echo "Sending " . $row['mtype'] . " to " . $row['tomail'] . "\n"; } if (empty($row['tomail'])) { if ($dbg > 2) { echo "No recepient specified!\n"; } continue; } $mai = new Mailer(); $mai->setTo('', $row['tomail']); $mai->setFrom($row['fromname'], $row['fromemail']); // Format parameters $defargs = array(); parse_str($row['defargs'], $defargs); $defargs['mdate'] = $row['mdate']; $toargs = array(); parse_str($row['args'], $toargs); $args = array_merge($defargs, $toargs); if ($dbg > 2) { echo "Arguments:"; print_r($args); echo "\n"; } $mai->setSubject(str_alparams($row['subject'], $args), "UTF-8"); $mai->body = new Mailer_TextBody(str_alparams($row['message'], $args)); if ($dry) { $mai->PrintMail(); continue; } try { if ($dbg > 2) { echo "Sending mail.."; } $mai->SendMail(); if ($dbg > 2) { echo " done.\n"; } update_mailing($dbhandle, $row['id'], true, $dbg); } catch (Exception $ex) { if ($dbg > 2) { echo " failed.\n"; } update_mailing($dbhandle, $row['id'], false, $dbg); throw $ex; } } } catch (Exception $ex) { if ($dbg > 1) { echo "Exception: " . $ex->getMessage(); } } return true; }
public function process($params) { if (!isset($params[0])) { throw new MException("Mod id not specified."); } $modId = $params[0]; $sth = $this->getDB()->prepare("SELECT id, name, version, versionCode, available, devname, devemail\r\n\t\t\t\t\t\tFROM mods\r\n\t\t\t\t\t\tWHERE id = :id"); $sth->bindValue(":id", $modId, PDO::PARAM_INT); $sth->execute(); $modExists = $sth->fetch(PDO::FETCH_ASSOC); if (!empty($modExists)) { // this mod is in the repo if ($modExists["available"] == 0) { throw new MException("This mod is not made available yet."); } else { // mod is already available $newVersion = $modExists["version"] + 1; $fileLocation = sprintf('%1$s../downloads/mods/%2$s/%3$d/%2$s.mod.dll', MBASE_PATH, $modExists["name"], $newVersion); if (!file_exists($fileLocation)) { throw new MException(sprintf("Mod %s has no version %d in the repo yet.", $modExists["name"], $modExists["version"])); } else { // file exists on server, nothing to stop us from activating now :) // check the update queue whether new information has been submitted $sth = $this->getDB()->prepare("SELECT submitted, newversionCode\r\n\t\t\t\t\t\t\t\t\tFROM updatequeue\r\n\t\t\t\t\t\t\t\t\tWHERE modid = :id"); $sth->bindValue(":id", $modExists["id"], PDO::PARAM_INT); $sth->execute(); $newVersionInfo = $sth->fetch(PDO::FETCH_ASSOC); $lastUpdate = time(); // use current time if there's no update $versionCode = $modExists["versionCode"]; // use old version code if new code is not submitted if (!empty($newVersionInfo)) { $lastUpdate = $newVersionInfo["submitted"]; $versionCode = $newVersionInfo["newversionCode"]; // and remove update from queue $sth = $this->getDB()->prepare("DELETE FROM updatequeue\r\n\t\t\t\t\t\t\t\t\t\tWHERE modid = :id"); $sth->bindValue(":id", $modExists["id"], PDO::PARAM_INT); if ($sth->execute()) { echo "Mod update request removed from queue.\n"; } else { echo "Mod update was not in queue.\n"; } } // now update the mod in the database so the update is public $sth = $this->getDB()->prepare("UPDATE mods\r\n\t\t\t\t\t\t\t\t\tSET version = :newversion, versionCode = :newversionCode, lastupdate = :lastupdate\r\n\t\t\t\t\t\t\t\t\tWHERE id = :id"); $sth->bindValue(":newversion", $newVersion, PDO::PARAM_INT); $sth->bindValue(":newversionCode", $versionCode, PDO::PARAM_STR); $sth->bindValue(":lastupdate", $lastUpdate, PDO::PARAM_INT); $sth->bindValue(":id", $modExists["id"], PDO::PARAM_INT); if ($sth->execute()) { // send mail to developer to notify him of the update $m = new Mailer(new MailAddress("*****@*****.**", sprintf("%s Mod Repo", REPO_NAME))); $m->addRecipient(new MailAddress($modExists["devemail"], $modExists["devname"])); $m->setSubject("Your mod has been updated."); $tpl = $m->getMustache()->loadTemplate("mod_updated.mustache"); $m->setBody($tpl->render(array("REPONAME" => REPO_NAME, "REPOURL" => REPO_URL, "DEVNAME" => $modExists["devname"], "MODNAME" => $modExists["name"], "VERSION" => $newVersion, "VERSIONCODE" => $versionCode))); $m->send(); echo sprintf("Mod %s is now updated to version %d. Wait for the cache to update.\n", $modExists["name"], $newVersion); } else { throw new MException("Mot not made available, database error."); } } } } else { // mod is not in the submission queue throw new MException(sprintf("Mod %d does not exist in the submission queue.", $modId)); } }
public function resetPassword() { $this->view = new HTMLView(); if ($this->request->isPOST()) { $post = $this->request->postData(); $user = new UserModel(); if ($this->request->isQueryArgSet('token')) { if ($user->getUserForPasswordResetToken($this->request->queryArgValue('token'))) { $user->password = @$post['password']; if ($user->save()) { $user->deletePasswordResetTokens(); $alert = new Alert(Alert::SUCCESS); $alert->addMessage('Password Set, Please Login'); } else { $alert = new Alert(Alert::ERROR); $alert->addMessageArray($user->getErrors()); } $this->view->includeTemplate('auth.reset-password.password', ['app_name' => AppConfig::getValue('app_name'), 'alert' => $alert]); } else { AppController::redirect(RouteController::fqURL('resetPassword'), ['status' => 'token-expired']); } } else { if ($post['email'] && $user->find($post['email'], 'email')) { $token = $user->getPasswordResetTokenData(); if ($token['last_email_timestamp'] <= Carbon::now()->subMinutes(pow(2, $token['email_attempts']))) { $user->incrementPasswordResetEmailCount(); $link = addQueryParams(RouteController::fqURL('resetPassword'), ['token' => $token['token']]); // Send Email $mailer = new Mailer(); $mailer->setSubject('Password Reset Token'); $mailer->addAddress($user->email); $mailer->includeHTMLTemplate('email.reset-password', ['link' => $link]); $mailer->send(); // errors handled within // Show Message $alert = new Alert(Alert::SUCCESS); $alert->addMessage('Email Sent'); } else { $alert = new Alert(Alert::ERROR); $alert->addMessage('Too Many Attempts, Please Try Again Later'); } $this->view->includeTemplate('auth.reset-password.email', ['app_name' => AppConfig::getValue('app_name'), 'alert' => $alert]); } else { $alert = new Alert(Alert::ERROR); $alert->addMessage('Email is Invalid/Non-Existent'); $this->view->includeTemplate('auth.reset-password.email', ['app_name' => AppConfig::getValue('app_name'), 'alert' => $alert]); } } } else { if ($this->request->isQueryArgSet('token')) { $user = new UserModel(); if ($user->getUserForPasswordResetToken($this->request->queryArgValue('token'))) { $this->view->includeTemplate('auth.reset-password.password', ['app_name' => AppConfig::getValue('app_name')]); } else { AppController::redirect(RouteController::fqURL('resetPassword'), ['status' => 'token-expired']); } } else { if ($this->request->isQueryArgSet('status') && $this->request->queryArgValue('status') == 'token-expired') { $alert = new Alert(Alert::ERROR); $alert->addMessage('Token is Invalid/Expired, Please Request a New One'); } $this->view->includeTemplate('auth.reset-password.email', ['app_name' => AppConfig::getValue('app_name'), 'alert' => isset($alert) ? $alert : null]); } } $this->view->render(true); }