'v3.1'] ); $data = ['Messages' => []] ; foreach($usersArray as $user) { $data['Messages'][] = [ 'From' => [ 'Email' => $email->getFromEmail(), 'Name' => $email->getFromName() ], 'To' => [ [ 'Email' => $user['email'], 'Name' => $user['name'].' '.$user['lastname'] ] ], 'Subject' => $email->getSubject(), 'HTMLPart' => $email->getHtmlContent(), 'TextPart' => $email->getTextContent() ] ; if(count($data['Messages']) == 50) { $this->requestPostEmailViaApi($client, $data); $data['Messages'] = [] ; } } if(count($data['Messages']) > 0) { $this->requestPostEmailViaApi($client, $data); } } public function requestPostEmailViaApi(Client $client, array $data) { $client->post(\Mailjet\Resources::$Email, ['body' => $data]); } }