Esempio n. 1
0
 /**
  * Send e-mail to particular user.
  *
  * @access     public
  * @param      string $sSubject
  * @param      string $sBody
  * @return     bool
  * @since      3.5.0, 2015-02-17
  * @version    3.5.0, 2015-02-17
  */
 public function sendEmail($sSubject, $sBody)
 {
     if ($this->getEmail() !== NULL) {
         $oMail = new Mail();
         $oMail->setFrom(Config::get('base.email'));
         $oMail->setTo($this->getEmail());
         $oMail->setSubject($sSubject);
         $oMail->setBody($sBody, 'text/html');
         return Mailer::factory()->send($oMail);
     }
     return FALSE;
 }
Esempio n. 2
0
 /**
  * Send user account activation code.
  *
  * @access     public
  * @param      string    $sPassword
  * @param      UserModel $oUser
  * @return     bool
  * @throws     \Plethora\Exception
  * @throws     \Plethora\Exception\Fatal
  * @since      1.0.0
  * @version    2.1.0-dev
  */
 private function sendActivationCode($sPassword, UserModel $oUser)
 {
     $sUserAgent = filter_input(INPUT_SERVER, 'HTTP_USER_AGENT');
     $sActivationCode1 = mb_strlen($sPassword) * time() . $sUserAgent . $oUser->getLogin();
     $sActivationCode2 = sha1($sActivationCode1);
     $sActivationCode = base64_encode($sActivationCode2);
     $oActivationCode = new ActivationCodeModel();
     $oActivationCode->setUser($oUser);
     $oActivationCode->setCode($sActivationCode);
     DB::persist($oActivationCode);
     DB::flush();
     $sSubject = __(':appname - Activation link', ['appname' => Plethora\Core::getAppName()]);
     $mailContent = View::factory("user/frontend/register/message")->render(['sLogin' => $oUser->getLogin(), 'sActivationCode' => $sActivationCode]);
     $mailView = View::factory('base/email');
     $mailView->bind('sContent', $mailContent);
     $mailView->set('sTitle', $sSubject);
     $mail = $mailView->render();
     $oMessage = new Mail();
     $oMessage->setSubject($sSubject);
     $oMessage->setFrom(Config::get('base.email'));
     $oMessage->setTo($oUser->getEmail());
     $oMessage->setBody($mail, 'text/html');
     return Mailer::factory()->send($oMessage);
 }