<?phpnamespace App\Service;use Mailjet\Client;use Mailjet\Resources;class Mailjet{ private $api_key = "83fdc7c5f9e50a3dd7b8fc554805fdc8"; private $api_secret = "b43ff1b0323954b73575f5a62f7968c6"; public function send($from_email, $from_name, $to_email, $to_name, $subject, $content, $contract = false, $booking = false, $tpl_id) { $mj = new Client($this->api_key, $this->api_secret, true, ['version' => 'v3.1']); if ($contract != false && $booking != false) { $body = [ 'Messages' => [ [ 'From' => [ 'Email' => $from_email, 'Name' => $from_name ], 'To' => [ [ 'Email' => $to_email, 'Name' => $to_name ] ], 'TemplateID' => $tpl_id, 'TemplateLanguage' => true, 'Subject' => $subject, 'Variables' => [ 'content' => $content, ], 'Attachments' => [ [ 'ContentType' => "application/pdf", 'Filename' => "contrat-de-location-saisonniere.pdf", 'Base64Content' => $contract ] ] ] ] ]; } else { $body = [ 'Messages' => [ [ 'From' => [ 'Email' => $from_email, 'Name' => $from_name ], 'To' => [ [ 'Email' => $to_email, 'Name' => $to_name ] ], 'TemplateID' => $tpl_id, 'TemplateLanguage' => true, 'Subject' => $subject, 'Variables' => [ 'content' => $content, ] ] ] ]; } $response = $mj->post(Resources::$Email, ['body' => $body]); $response->success(); }}