load('account'); $accountAttributes = $invoice->account()->getParent()->getRelations()['account']->getAttributes(); $pdfPath = storage_path().'/pdfcache/cache-'.$invoice->id.'.pdf'; if($accountAttributes['pdf_email_attachment'] === 1 && file_exists($pdfPath)) { $message->attach( $pdfPath, array('as' => $accountAttributes['name'].'_'.$accountAttributes['invoice_number_prefix'].$invoice->getName().'.pdf', 'mime' => 'application/pdf') ); } } //$message->setEncoder(\Swift_Encoding::get8BitEncoding()); $message->to($toEmail)->from($fromEmail, $fromName)->replyTo($replyEmail, $fromName)->subject($subject); }); } }