/** * @brief 发送到货通知邮件 */ function notify_send() { $smtp = new SendMail(); $error = $smtp->getError(); if ($error) { $return = array('isError' => true, 'message' => $error); echo JSON::encode($return); exit; } $notify_ids = IFilter::act(IReq::get('notifyid')); $message = ''; if ($notify_ids && is_array($notify_ids)) { $ids = join(',', $notify_ids); $query = new IQuery("notify_registry as notify"); $query->join = "right join goods as goods on notify.goods_id=goods.id left join user as u on notify.user_id = u.id"; $query->fields = "notify.*,u.username,goods.name as goods_name,goods.store_nums"; $query->where = "notify.id in(" . $ids . ")"; $items = $query->find(); //库存大于0,且处于未发送状态的 发送通知 $succeed = 0; $failed = 0; $tb_notify_registry = new IModel('notify_registry'); foreach ($items as $value) { $body = mailTemplate::notify(array('{goodsName}' => $value['goods_name'], '{url}' => IUrl::getHost() . IUrl::creatUrl('/site/products/id/' . $value['goods_id']))); $status = $smtp->send($value['email'], "到货通知", $body); if ($status) { //发送成功 $succeed++; $data = array('notify_time' => ITime::getDateTime(), 'notify_status' => '1'); $tb_notify_registry->setData($data); $tb_notify_registry->update('id=' . $value['id']); } else { //发送失败 $failed++; } } } $return = array('isError' => false, 'count' => count($items), 'succeed' => $succeed, 'failed' => $failed); echo JSON::encode($return); }
/** * @brief 发送验证邮箱邮件 */ public function send_check_mail() { $email = IReq::get('email'); if (IValidate::email($email) == false) { IError::show(403, '邮件格式错误'); } $userDB = new IModel('user'); $userRow = $userDB->getObj('email = "' . $email . '"'); $code = base64_encode($userRow['email'] . "|" . $userRow['id']); $url = IUrl::getHost() . IUrl::creatUrl("/simple/check_mail/code/{$code}"); $content = mailTemplate::checkMail(array("{url}" => $url)); //发送邮件 $smtp = new SendMail(); $result = $smtp->send($email, "用户注册邮箱验证", $content); if ($result === false) { IError::show(403, "发信失败,请重试!或者联系管理员查看邮件服务是否开启"); } $message = "您的邮箱验证邮件已发送到{$email}!请到您的邮箱中去激活"; $this->redirect('/site/success?message=' . urlencode($message) . '&email=' . $email); }