/** * 发送邮件给新的邮箱地址 * @param User $user * @param string $email * @param string $password * @throws \Exception */ public function edit_email_send_mail($user, $email, $password) { lib()->load('UserCheck', 'MailTemplate'); $email = strtolower(trim($email)); if ($user->getPassword() !== UserCheck::CreatePassword($password, $user->getSalt())) { $this->throwMsg(-10); } $email_check = UserCheck::CheckEmail($email); if ($email_check !== true) { throw new \Exception($email_check); } $meta = ['edit_email_add' => $email, 'edit_email_time' => date("Y-m-d H:i:s"), 'edit_email_code' => salt_hash($email . $user->getEmail(), salt())]; $user->getMeta()->set($meta); $mt = new MailTemplate("edit_email.html"); $mt->setUserInfo($user->getInfo()); $mt->setValues(['verify_code' => $meta['edit_email_code']]); $mt->mailSend($user->getName(), $email); }
/** * 发送消息给关注用户 * @param null $rt * @param int $f_id 被关注ID * @param int $u_id 关注者ID * @return null */ public function message_follow_me($rt, $f_id, $u_id) { try { if ($this->notice($f_id, 'message', 'follow_me')) { $user = User::getUser($u_id); $follow_user = User::getUser($f_id); $mt = new MailTemplate("message_notice/follow_me.md"); $mt->setUserInfo($follow_user->getInfo()); $mt->setValues(['follow_user_aliases' => $user->getAliases(), 'follow_user_url' => user_link($user->getName()), 'follow_list_link' => get_url('Follow', 'ta'), 'follow_user_name' => $user->getName()]); $this->message->addNoticeMsg($mt->getTitle(), $mt->getContent(), $f_id); } } catch (\Exception $ex) { Log::write(_("Message to message_follow_me create a Exception.") . "EX:[" . $ex->getCode() . "]:" . $ex->getMessage(), Log::NOTICE); } return $rt; }
/** * 向对应的用户发送激活邮件 * @param $user \ULib\User * @return bool */ public function SendActivationMail(&$user) { lib()->load('MailTemplate'); try { $mt = new MailTemplate("activation.html"); $mt->setUserInfo($user->getInfo()); $mt->setValues(["activation_url" => $this->CreateActivationUrl($user)]); $mt->mailSend($user->getName(), $user->getEmail()); return true; } catch (\Exception $ex) { $this->activation_msg = $ex->getMessage(); } return false; }