count() === 1) { $repository->attachRole($event->user, 'owner'); } return true; } /** * @param RequestedNewPassword $event * * @return bool */ public function sendNewPassword(RequestedNewPassword $event): bool { $email = $event->user->email; $ipAddress = $event->ipAddress; $token = $event->token; $url = route('password.reset', [$token]); // send email. try { Mail::send( ['emails.password-html', 'emails.password-text'], ['url' => $url, 'ip' => $ipAddress], function (Message $message) use ($email) { $message->to($email, $email)->subject('Your password reset request'); } ); } catch (Swift_TransportException $e) { Log::error($e->getMessage()); } return true; } /** * This method will send the user a registration mail, welcoming him or her to Firefly III. * This message is only sent when the configuration of Firefly III says so. * * @param RegisteredUser $event * * @return bool */ public function sendRegistrationMail(RegisteredUser $event) { $sendMail = env('SEND_REGISTRATION_MAIL', true); if (!$sendMail) { return true; } // get the email address $email = $event->user->email; $address = route('index'); $ipAddress = $event->ipAddress; // send email. try { Mail::send( ['emails.registered-html', 'emails.registered-text'], ['address' => $address, 'ip' => $ipAddress], function (Message $message) use ($email) { $message->to($email, $email)->subject('Welcome to Firefly III!'); } ); } catch (Swift_TransportException $e) { Log::error($e->getMessage()); } return true; } }