Exemplo n.º 1
0
 /**
  * Accept the password change, send new password to user
  *
  * @return array
  */
 public function retrieve_accepted()
 {
     if (!$this->_params['token']) {
         return array('success' => false, 'message' => 'Invalid token for password change.');
     }
     // Try to connect database = if an error occurs, it will return an array, nothing otherwise
     if ($connect = $this->_connect_oauth()) {
         return $connect;
     }
     $user = User::where('user_password_change_token', '=', $this->_params['token'])->first();
     if (is_object($user)) {
         $new_password = $this->_random_password();
         $user->user_password = $this->_hash_password($new_password);
         $user->user_password_change_token = '';
         $user->save();
         // Create email
         $mail = new \Ieru\Ieruapis\Organic\PHPMailer();
         $mail->WordWrap = 50;
         $mail->IsHTML(true);
         $mail->From = '*****@*****.**';
         $mail->FromName = 'Organic.Edunet';
         $mail->AddAddress($user->user_email);
         // Add a recipient
         $mail->AddReplyTo('*****@*****.**', 'Information');
         $mail->Subject = '[Organic.Edunet] Account password changed';
         $mail->Body = '<p>Your account password has been changed to username "' . $user->user_username . '": ' . $new_password . '</p>';
         $mail->AltBody = "Your account password has been changed to '" . $user->user_username . "': " . $new_password;
         $mail->Send();
     } else {
         return array('success' => false, 'message' => 'Incorrect token for password change.');
     }
     return array('success' => true, 'message' => 'Password changed and mail sent.');
 }
Exemplo n.º 2
0
 /**
  * Sends an activation email to the user
  *
  * @param   array   &$data  The user information registering
  * @return  void
  */
 private function _send_feedback(&$data)
 {
     $mail = new \Ieru\Ieruapis\Organic\PHPMailer();
     $mail->From = '*****@*****.**';
     $mail->FromName = 'Organic.Edunet';
     $mail->AddAddress('*****@*****.**');
     $mail->AddAddress('*****@*****.**');
     $mail->AddAddress('*****@*****.**');
     $mail->AddReplyTo('*****@*****.**', 'Information');
     $mail->WordWrap = 50;
     // Set word wrap to 50 characters
     $mail->IsHTML(true);
     // Set email format to HTML
     $mail->Subject = '[Organic.Edunet] [Feedback] ' . $data['form-feedback-subject'];
     $mail->Body = '<p>New feedback has been received from an user: '******'form-feedback-email'] . '</p><p>------------------------</p><div>' . nl2br($data['form-feedback-body'], true) . '</div>';
     $mail->AltBody = "New feedback has been received from an user, as follows:\n" . $data['form-feedback-body'];
 }