diff --git a/application/api/controller/Email.php b/application/api/controller/Email.php index 57b15ca..aa50092 100644 --- a/application/api/controller/Email.php +++ b/application/api/controller/Email.php @@ -275,6 +275,30 @@ die; } + + public function myPush(){ +// phpinfo();die; +// $data = $this->request->post(); +// $rule = new Validate([ +// "email"=>"require", +// "title"=>"require", +// "content"=>"require" +// ]); +// if(!$rule->check($data)){ +// return jsonError($rule->getError()); +// } + + $data['email'] = "751475802@qq.com"; + $data['title'] = "test title"; + $data['content'] = "content"; + + + echo sendMyEmail($data['email'],$data['title'],$data['content']); + } + + + + public function lsPushEmail() { // $journal_info = $this->journal_obj->where("journal_id", 4)->find(); diff --git a/application/api/controller/EmailService.php b/application/api/controller/EmailService.php deleted file mode 100644 index cbad674..0000000 --- a/application/api/controller/EmailService.php +++ /dev/null @@ -1,46 +0,0 @@ -request->post(); - $rule = new Validate([ - "password" => "require" - ]); - if (!$rule->check($data)) { - return jsonError($rule->getError()); - } - $password = $data['password']; - if (function_exists('openssl_random_pseudo_bytes')) { - $salt = substr(str_replace('+', '.', base64_encode(openssl_random_pseudo_bytes(6))), 0, 8); - } else { - // 使用 mt_rand 作为后备方法 - $salt = ''; - for ($i = 0; $i < 8; $i++) { - $salt .= chr(mt_rand(33, 126)); // 生成随机字符 - } - } - $hashed_password = crypt($password, '$1$' . $salt . '$'); - - return jsonSuccess(["result"=>$hashed_password]); - -// return $hashed_password; - - - } -} \ No newline at end of file diff --git a/application/api/controller/Super.php b/application/api/controller/Super.php index c81fcc7..7b162ad 100644 --- a/application/api/controller/Super.php +++ b/application/api/controller/Super.php @@ -355,9 +355,6 @@ class Super extends Controller { $journal_info = $this->journal_obj->where('journal_id',$journalId)->find(); $zc_num = $this->article_obj->where('accept_sn','like',$journal_info['abbr'].'%')->where('journal_id','<>',$journalId)->where('ctime','>',$start_time)->where('ctime','<',$end_time)->count(); - -// echo $this->article_obj->getLastSql();die; - $zr_num = $this->article_obj->where('accept_sn','not like',$journal_info['abbr'].'%')->where('journal_id',$journalId)->where('ctime','>',$start_time)->where('ctime','<',$end_time)->count(); //获取全部总数 $mq_num = $this->article_obj @@ -365,7 +362,6 @@ class Super extends Controller { ->where('ctime','>',$start_time) ->where('ctime','<',$end_time) ->count(); - echo $this->article_obj->getLastSql();die; $res['mq'] = $mq_num;//文章总数 $res['zc'] = $zc_num;//转出文章数 $res['zr'] = $zr_num;//转入文章数 diff --git a/application/common.php b/application/common.php index 79d11c8..80b219c 100644 --- a/application/common.php +++ b/application/common.php @@ -278,6 +278,52 @@ function search_array_val($arr, $val) } } + +function sendMyEmail($email,$title,$content){ + + $mail = new PHPMailer(true); + + try { + // 服务器设置 + $mail->isSMTP(); + $mail->Host = 'smtp.tmrjournals.com.cn'; // SMTP 服务器 + $mail->SMTPAuth = true; + $mail->Username = 'wangjinlei@tmrjournals.com.cn'; // SMTP 用户名 + $mail->Password = '123456qwe'; +// $mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS; // Enable STARTTLS encryption +// $mail->Port = 587; // TCP port for STARTTLS +// $mail->SMTPDebug = 2; // Enable debugging for detailed output +// $mail->SMTPSecure = ''; // 不使用 SSL 或 TLS +// $mail->Port = 25; + $mail->SMTPSecure = false; // 禁用TLS/SSL加密 + $mail->SMTPAutoTLS = false; // 禁用自动TLS加密 + $mail->Port = 25; // 非加密的SMTP通常使用端口25 + // 收件人设置 + $mail->setFrom('wangjinlei@tmrjournals.com.cn', 'tmr'); + $mail->addAddress($email, $email); // 添加一个收件人 + $mail->addReplyTo('wangjinlei@tmrjournals.com.cn', 'repack'); + + // 附件(可选) + // $mail->addAttachment('/var/tmp/file.tar.gz'); + // $mail->addAttachment('/tmp/image.jpg', 'new.jpg'); + + // 内容 + $mail->isHTML(true); // 设置邮件格式为 HTML + $mail->Subject = $title; + $pre = Env::get('emailtemplete.pre'); + $net = Env::get('emailtemplete.net'); + $net = str_replace("{{email}}", 'wangjinlei@tmrjournals.com.cn', $net); + $bo = $pre.$content.$net; + $mail->Body = $bo; + $mail->AltBody = $content; + + $mail->send(); + echo 'Message has been sent'; + } catch (Exception $e) { + echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}"; + } +} + function GptChar($message,$ckey) { $url = 'https://api.openai.com/v1/chat/completions'; diff --git a/composer.json b/composer.json index 47385a6..3f77820 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ "php": ">=5.4.0", "topthink/framework": "5.0.*", "topthink/think-captcha": "1.*", - "phpmailer/phpmailer": "^6.1", + "phpmailer/phpmailer": "^6.9", "tecnickcom/tcpdf": "^6.3", "weiwei/api-doc": "^1.6", "topthink/think-queue": "1.1.4", diff --git a/vendor/composer/installed.php b/vendor/composer/installed.php index e4ee738..d4364d9 100644 --- a/vendor/composer/installed.php +++ b/vendor/composer/installed.php @@ -3,7 +3,7 @@ 'name' => 'topthink/think', 'pretty_version' => 'dev-master', 'version' => 'dev-master', - 'reference' => '881ac3e056b44443399cc70fcd00babeecddaaa0', + 'reference' => '1f7220f36e66f33fb9d3867ecb1856a4d2fb0ae5', 'type' => 'project', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), @@ -175,7 +175,7 @@ 'topthink/think' => array( 'pretty_version' => 'dev-master', 'version' => 'dev-master', - 'reference' => '881ac3e056b44443399cc70fcd00babeecddaaa0', + 'reference' => '1f7220f36e66f33fb9d3867ecb1856a4d2fb0ae5', 'type' => 'project', 'install_path' => __DIR__ . '/../../', 'aliases' => array(),