Exemple #1
0
 public function __construct($key)
 {
     parent::__construct();
     $newPassword = uniqid();
     $reset = \Pecee\Model\User\UserReset::confirm($key, $newPassword);
     if ($reset) {
         $user = ModelUser::getById($reset);
         if ($user->hasRow()) {
             // Send mail with new password
             // TODO: Move this shit to separate html template
             $user->setEmailConfirmed(true);
             $user->update();
             $text = "Dear customer!\n\nWe've reset your password - you can login with your e-mail and the new password provided below:\nNew password: "******"\n\nIf you have any questions, feel free to contact us any time.\n\nKind regards,\nThe NinjaImg Team";
             $transport = \Swift_SendmailTransport::newInstance(env('MAIL_TRANSPORT') . ' -bs');
             $swift = \Swift_Mailer::newInstance($transport);
             $message = new \Swift_Message(lang('New password for NinjaImg'));
             $message->setFrom(env('MAIL_FROM'));
             $message->setSender(env('MAIL_FROM'));
             $message->setReplyTo(env('MAIL_FROM'));
             $message->setBody($text, 'text/plain');
             $message->setTo($user->username);
             $swift->send($message);
             $this->setMessage('A new password has been sent to your e-mail.', 'success');
             redirect(url('user.login'));
         }
         redirect(url('home'));
     }
 }
Exemple #2
0
 protected function invitationAcceptedMail(OrganisationInvite $invite, ModelOrganisation $organisation, ModelUser $user)
 {
     $senderUser = ModelUser::getById($invite->user_id);
     if ($senderUser->hasRow() && !$senderUser->deleted) {
         $transport = \Swift_SendmailTransport::newInstance(env('MAIL_TRANSPORT') . ' -bs');
         $swift = \Swift_Mailer::newInstance($transport);
         $message = new \Swift_Message(lang('Invitation to ' . $organisation->name . ' accepted'));
         $message->setFrom(env('MAIL_FROM'));
         $message->setSender(env('MAIL_FROM'));
         $message->setReplyTo(env('MAIL_FROM'));
         $message->setBody("Dear {$senderUser->data->name}!\n\nWe are writing to inform you, that {$user->data->name} has just accepted your invitation to join the organisation {$organisation->name} on NinjaImg.\n\nIf you have any questions, feel free to contact us any time.\n\nKind regards,\nThe NinjaImg Team", 'text/plain');
         $message->setTo($senderUser->username);
         $swift->send($message);
     }
 }