Mailjet is a powerful cloud-based email delivery service, here’s a quick example on how to send a transactional email with their API v3.1. To make sure your emails make it to the inbox, verify your sender domain and setup the SPF/DKIM authentication.
<?php $mailjetApiKey = ''; $mailjetApiSecret = ''; $messageData = [ 'Messages' => [ [ 'From' => [ 'Email' => '[email protected]', 'Name' => 'from name' ], 'To' => [ [ 'Email' => '[email protected]', 'Name' => 'to name' ] ], 'Subject' => 'Mailjet test email', 'TextPart' => 'Mailjet test body email message', 'HTMLPart' => '<strong>Mailjet test body email message</strong>' ] ] ]; $jsonData = json_encode($messageData); $ch = curl_init('https://api.mailjet.com/v3.1/send'); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST'); curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonData); curl_setopt($ch, CURLOPT_USERPWD, "{$mailjetApiKey}:{$mailjetApiSecret}"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'Content-Type: application/json', 'Content-Length: ' . strlen($jsonData) ]); $response = json_decode(curl_exec($ch)); var_dump($response);
You can also use their official Mailjet PHP Wrapper.