public function sendResetLink($data) { $userDao = new UsersDao(); $user = $userDao->getUserByParam('email', $data['email']); if ($user->isEmpty()) { throw new \Exception("Email is not registered"); } $user = $user[0]; $hash = md5(time() . $user->id . 'ASKLD128fjsdfksfuewqekjsu'); $user->reset_hash = $hash; $user->save(); // send mail $mailService = new MailService(); $passwordArray = array(); $passwordArray['to'] = $user->email; $passwordArray['user_object'] = $user; $webClient = env('WEB_CLIENT'); $passwordArray['reset_link'] = $webClient . "#/resetpassword/" . $hash; $passwordArray['user_object'] = $user; $sent = $mailService->resetPasswordMail($passwordArray); if ($sent) { return "Succesfully sent"; } else { return "Error sending mail"; } }
/** * Notify admin via e-mail using the data from the array. * * @param array $data Array of data, including the possible file * * @return bool Whether sending the message succeeded. */ public function notifyAdmin($data) { try { $this->mail_service->sendNotification($data); } catch (\Exception $e) { return false; } return true; }
/** * Handle the event. * * @param EnquiryWasMade $event * @return void */ public function handle(EnquiryWasMade $event) { $enquiryDao = new EnquiryDao(); $enquiryArrayObject = $enquiryDao->getEnquiryByStatus(); if (!empty($enquiryArrayObject)) { $mailService = new MailService(); $mailService->sendProductEnquiryMail($enquiryArrayObject); } return false; }
/** * @param \App\Async\Jobs\Job $job * @return bool */ public function execute($job) { $userId = $job->user_id; $user = $this->userRepository->find($userId); if (empty($user)) { return false; } $this->mailService->sendRegisteredMail($user); return true; }