1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- <?php
- namespace app\api\controller;
- use app\common\controller\Api;
- use app\common\library\Ems as Emslib;
- use app\common\model\User;
- use think\Hook;
- class Ems extends Api
- {
- protected $noNeedLogin = '*';
- protected $noNeedRight = '*';
- public function _initialize()
- {
- parent::_initialize();
- }
-
- public function send()
- {
- $email = input("email");
- $event = input("event",'default');
- $last = Emslib::get($email, $event);
- if ($last && time() - $last['createtime'] < 60) {
- $this->error(__('发送频繁'));
- }
- if ($event) {
- $userinfo = User::getByEmail($email);
- if ($event == 'register' && $userinfo) {
-
- $this->error(__('已被注册'));
- } elseif (in_array($event, ['changeemail']) && $userinfo) {
-
- $this->error(__('已被占用'));
- } elseif (in_array($event, ['changepwd', 'resetpwd']) && !$userinfo) {
-
- $this->error(__('未注册'));
- }
- }
- $ret = Emslib::send($email, null, $event);
- if ($ret) {
- $this->success(__('发送成功'));
- } else {
- $this->error(__('发送失败'));
- }
- }
-
-
- }
|