'Champs obligatoire'], ]; } /** * @inheritdoc */ public function attributeLabels() { return [ 'subject' => 'Sujet', 'message' => 'Message', ]; } /** * Envoie un email aux utilisateurs d'un point de vente ou à tous les * utilisateurs d'un producteur. * * @param integer $idPointSale ID du point de vente */ public function sendEmail($usersArray) { $producer = Producer::getCurrent() ; $mj = new \Mailjet\Client( $producer->getApiKeyMailjet('public'), $producer->getApiKeyMailjet('private'), true, ['version' => 'v3.1'] ); $body = ['Messages' => []] ; foreach($usersArray as $user) { $body['Messages'][] = [ 'From' => [ 'Email' => $producer->slug.'@laboiteapain.net', 'Name' => $producer->name ], 'To' => [ [ 'Email' => $user['email'], 'Name' => $user['name'].' '.$user['lastname'] ] ], 'Subject' => $this->subject, 'TextPart' => $this->message, 'HTMLPart' => nl2br($this->message) ] ; } $response = $mj->post(\Mailjet\Resources::$Email, ['body' => $body]); return $response->success() ; } }