Ejemplo n.º 1
0
 protected function sendCustomerMail(OrganisationInvoice $invoice)
 {
     $users = ModelUser::getByOrganisationId($this->organisation->id, UserRole::TYPE_OWNER);
     if ($users->hasRows()) {
         foreach ($users as $user) {
             $transport = \Swift_SendmailTransport::newInstance(env('MAIL_TRANSPORT') . ' -bs');
             $swift = \Swift_Mailer::newInstance($transport);
             $message = new \Swift_Message(lang('New invoice available for ' . $this->organisation->name));
             $currency = ModelSettings::getInstance()->data->default_currency_character;
             $message->setFrom(env('MAIL_FROM'));
             $message->setSender(env('MAIL_FROM'));
             $message->setReplyTo(env('MAIL_FROM'));
             $message->setBody("Dear {$user->data->name}!\n\nAttached is the latest invoice from NinjaImg.\n\nThe amount for invoice {$invoice->invoice_id} is {$invoice->amount_total}{$currency} with payment date {$invoice->due_date}.\n\nYou can always view your invoices at your controlpanel on ninjaimg.com.\n\nThanks for supporting our service, we really appreciate it!\n\nIf you have any questions, feel free to contact us any time.\n\nKind regards,\nThe NinjaImg Team", 'text/plain');
             $message->setTo($user->username);
             $attachment = new \Swift_Attachment(file_get_contents($invoice->path), basename($invoice->path), File::getMime($invoice->path));
             $message->attach($attachment);
             $swift->send($message);
         }
     }
 }