Example #1
0
 /**
  * @param string $toAddress Single address to send to
  * @param string[] $ccList
  * @param string $subject Email subject
  * @param string $body Email body
  * @return array                      Array of failed addresses
  */
 public function sendEmail($toAddress, $ccList, $subject, $body)
 {
     $email = new EmailHelper();
     $email->setEmailTo($toAddress, $toAddress);
     $email->setSubject($subject);
     $email->setBody($body);
     $email->setHtml(true);
     if (is_array($ccList) && count($ccList)) {
         foreach ($ccList as $address) {
             $email->addCc($address, $address);
         }
     }
     return $email->send();
 }
Example #2
0
    public function forgotPassword()
    {
        if ($this->request->getMethod() == 'POST') {
            $email = $this->getParam('email', null);
            $user = $this->userStore->getByEmail($email);
            if (empty($user)) {
                $this->view->error = 'No user exists with that email address, please try again.';
                return $this->view->render();
            }
            $key = md5(date('Y-m-d') . $user->getHash());
            $url = PHPCI_URL;
            $name = $user->getName();
            $userId = $user->getId();
            $message = <<<MSG
Hi {$name},

You have received this email because you, or someone else, has requested a password reset for PHPCI.

If this was you, please click the following link to reset your password: {$url}session/reset-password/{$userId}/{$key}

Otherwise, please ignore this email and no action will be taken.

Thank you,

PHPCI
MSG;
            $email = new Email();
            $email->setEmailTo($user->getEmail(), $user->getName());
            $email->setSubject('Password reset');
            $email->setBody($message);
            $email->send();
            $this->view->emailed = true;
        }
        return $this->view->render();
    }
 /**
  * Allows the user to request a password reset email.
  * @return string
  */
 public function forgotPassword()
 {
     if ($this->request->getMethod() == 'POST') {
         $email = $this->getParam('email', null);
         $user = $this->userStore->getByEmail($email);
         if (empty($user)) {
             $this->view->error = Lang::get('reset_no_user_exists');
             return $this->view->render();
         }
         $key = md5(date('Y-m-d') . $user->getHash());
         $url = PHPCI_URL;
         $message = Lang::get('reset_email_body', $user->getName(), $url, $user->getId(), $key);
         $email = new Email();
         $email->setEmailTo($user->getEmail(), $user->getName());
         $email->setSubject(Lang::get('reset_email_title', $user->getName()));
         $email->setBody($message);
         $email->send();
         $this->view->emailed = true;
     }
     return $this->view->render();
 }