コード例 #1
0
ファイル: UserService.php プロジェクト: kelliany/TestZilla
 /**
  * Send the verification email to the user.
  * @param  String $subject      - the subject of the email
  * @param  String $templateName - the template name of the email
  * @param  String $username     - the username of the user
  * @param  String $email        - the email of the user
  * @return whether the mail is successfully sent
  */
 private function sendVerificationEmail($subject, $templateName, $username, $email)
 {
     $token = uniqid();
     $tomorrowDateTime = date('Y-m-d H:i:s', strtotime('+1 day'));
     $emailVerification = EmailVerification::findFirst(array('conditions' => 'email = ?1', 'bind' => array(1 => $email)));
     if ($emailVerification != NULL) {
         $emailVerification->delete();
     }
     $emailVerification = new EmailVerification();
     $emailVerification->setEmail($email);
     $emailVerification->setToken($token);
     $emailVerification->setExpireTime($tomorrowDateTime);
     $emailVerification->create();
     $parameters = array('username' => $username, 'email' => $email, 'token' => $token);
     return $this->mailSender->sendMail($email, $subject, $templateName, $parameters);
 }