public function sendemailAction() { if ($this->request->isPost()) { $email = $this->request->getPost('email', 'email'); $did = $this->request->getPost('did'); if (isset($did)) { $time = time(); $emailContent = "亲爱的" . $email . ": \r\n"; $emailContent .= "欢迎您来到中合万邦费控系统! \r\n"; $emailContent .= "请马上点击以下链接完成注册 \r\n"; $emailContent .= "http://wap.zhwbchina.com/register/verifyemail/" . md5($time . "+" . $email) . "\r\n"; $emailContent .= "(如果该链接无法点击,请将它完成复制并粘贴至浏览器的地址栏中访问)\r\n\r\n\r\n"; $emailContent .= "这是一封系统自动发出的邮件,请不要直接回复。\r\n"; $emailContent .= "如有疑问可发送邮件至tech@zhwbchina.com。\r\n\r\n"; $emailContent .= "中合万邦\r\n"; $emailContent .= "http://www.zhwbchina.com"; $mail = new Mail(); $result = $mail->smtp($email, '请验证您的邮箱(自:中合万邦——费控系统)', $emailContent); //$result = true; $this->view->setVar("email", $email); $results = VerifyEmail::Find("email = '" . $email . "'"); foreach ($results as $result) { if ($result->delete() == false) { //存log foreach ($result->getMessages() as $message) { } } else { //存log } } $verifyEmail = new VerifyEmail(); $verifyEmail->email = $email; $verifyEmail->time = $time; $verifyEmail->verifyCode = md5($time . "+" . $email); $verifyEmail->active = 'Y'; $verifyEmail->did = $did; if ($verifyEmail->save() == false) { foreach ($user->getMessages() as $message) { $this->flash->error((string) $message); } } else { if ($result) { $arrRs = explode('@', $email); $mailLink = 'http://mail.' . $arrRs[1]; $this->view->setVar("mailLink", $mailLink); $this->flash->success('邮件已发送至您的邮箱,请查收!'); } else { $this->flash->error('发送失败!'); $this->forward('register/index'); } } } else { } } else { $this->response->redirect("index/index"); } }
<?php include_once "../includes/header.inc.php"; require_once "../Classes/User.class.php"; require_once "../Classes/VerifyEmail.class.php"; $user = new User(); $VEmail = new VerifyEmail(); if (isset($PARAMS['username']) && isset($PARAMS['password']) && isset($PARAMS['email'])) { $user->username = $PARAMS['username']; $user->Find(); if (!$user->variables) { $VEmail->email = $PARAMS['email']; $VEmail->Find(); if (!$VEmail->variables) { $user->username = $PARAMS['username']; $user->password = md5(base64_encode($PARAMS['password'])); $user->create_date = date("Ymd"); $user->email = $PARAMS['email']; $user->Create(); $VEmail->email = $PARAMS['email']; $VEmail->code = getNewCode(); $VEmail->username = $PARAMS['username']; $VEmail->Create(); sendVerificationEmail($VEmail->email, $user->username, $VEmail->code); $datos = array("status" => "OK"); print_r(json_encode($datos)); } elseif (!$VEmail->verified) { $datos = array("status" => "inUseNotVerified"); print_r(json_encode($datos)); } else { $datos = array("status" => "emailInUse"); print_r(json_encode($datos));