Example #1
0
 /**
  * 用户忘记密码找回
  * @param $username
  * @return string
  */
 public function forgetPassword($username)
 {
     $User = new UserLogic();
     $GreenMail = new GreenMail();
     $userDetail = $User->where(array('user_login' => $username))->find();
     if (!$userDetail) {
         return $this->jsonResult(0, "不存在用户");
     }
     $new_pass = encrypt($userDetail['user_session']);
     $User->where(array('user_email' => $userDetail['user_email']))->data(array('user_pass' => $new_pass))->save();
     $res = $GreenMail->sendMail($userDetail['user_email'], "", "用户密码重置", "新密码: " . $userDetail['user_session']);
     if ($res['statue']) {
         return $this->jsonResult(1, "新密码的邮件已经发送到注册邮箱");
     } else {
         return $this->jsonResult(0, "请检查邮件发送设置" . $res['info']);
     }
 }
 /**
  * 将已备份数据库文件通过系统邮箱发送到指定邮箱中
  */
 public function sendSql()
 {
     set_time_limit(0);
     if (IS_POST) {
         header('Content-Type:application/json; charset=utf-8');
         $sqlFiles = explode(',', $_POST['sqlFiles']);
         if (empty($sqlFiles) || count($sqlFiles) == 0 || $_POST['sqlFiles'] == "") {
             $this->jsonReturn(0, "请选择要打包的sql文件");
         }
         $files = isset($_SESSION['cacheSendSql']['files']) ? $_SESSION['cacheSendSql']['files'] : self::getSqlFilesGroups();
         $to = $_SESSION['cacheSendSql']['to'];
         $sum = $_SESSION['cacheSendSql']['count'];
         $zipOut = "sqlBackup.zip";
         if ($zip_res = File::zip($sqlFiles, $zipOut, WEB_CACHE_PATH)) {
             //$res = send_mail($to, "", "数据库备份", "网站:<b>" . get_opinion('title') . "</b> 数据文件备份", WEB_CACHE_PATH . $zipOut); //
             $GreenMailContent = new GreenMailContent();
             $GreenMailContent->to = $to;
             $GreenMailContent->subject = get_opinion('title') . date("Y-m-d") . "数据库备份";
             $GreenMailContent->body = "网站:<b>" . get_opinion('title') . "</b> 数据文件备份.生成时间:" . date("Y-m-d");
             $GreenMailContent->attachment = WEB_CACHE_PATH . $zipOut;
             $GreenMail = new GreenMail();
             $res = $GreenMail->send($GreenMailContent);
         } else {
             $this->jsonReturn(0, "发送失败");
         }
         File::delAll(WEB_CACHE_PATH . $zipOut);
         //删除已发送附件
         $time = time() - $_SESSION['cacheSendSql']['time'];
         unset($_SESSION['cacheSendSql']);
         if ($res['statue'] == true) {
             $this->jsonReturn(1, "sql文件已发送到你的邮件,请注意查收<br/>耗时:{$time} 秒");
         } else {
             $this->jsonReturn(0, $res['info']);
         }
     }
     $this->display();
 }
 /**
  * 邮箱发送测试
  */
 public function emailSendTest()
 {
     $this->assign('action', '邮件发送测试');
     if (IS_POST) {
         $send_to = I('post.to_mail');
         $subject = "GreenCMS测试邮件";
         $body = "测试邮件通过" . get_opinion('mail_method') . '模式发送';
         $Mail = new GreenMail();
         $res = $Mail->sendMail($send_to, "GreenCMS Test Team", $subject, $body);
         $this->assign("config", $Mail->config);
         $this->assign("res", $res);
         $this->display('emailRes');
     } else {
         $this->display('emailTest');
     }
 }