to($to)->subject($subject); if (!is_array($attachments)) { $attachments = explode("\n", str_replace("\r\n", "\n", $attachments)); } $attachments = array_filter($attachments); if (!empty($attachments)) { foreach ($attachments as $attachment) { $message->attach($attachment); } } }); return true; } }