faker = \Faker\Factory::create(); Model::reguard(); $this->makeTestData(); } public function test_initial_email_sends() { // \Log::error($this->invoice->makeValues()); $this->invoice->date = now(); $this->invoice->due_date = now()->addDays(7); $this->invoice->number = $this->getNextInvoiceNumber($this->client); $this->invoice->client = $this->client; $message_array = $this->invoice->getEmailData(); $message_array['title'] = &$message_array['subject']; $message_array['footer'] = 'The Footer'; // $template_style = $this->client->getSetting('email_style'); $template_style = 'light'; //iterate through the senders list and send from here $invitations = InvoiceInvitation::whereInvoiceId($this->invoice->id)->get(); $invitations->each(function($invitation) use($message_array, $template_style) { $contact = $invitation->contact; if($contact->send_invoice && $contact->email) { //there may be template variables left over for the specific contact? need to reparse here //change the runtime config of the mail provider here: //send message Mail::to($contact->email) ->send(new TemplateEmail($message_array, $template_style, $this->user, $contact->client)); //fire any events sleep(5);//here to cope with mailtrap time delays } }); } }