Email API Integration Guide with PHP

Minimum code that you need to integrate Mailazy with your PHP application


Prerequisites

You need to complete these given prerequisites, you can skip the step if you have already completed.

  1. Sign up for a Mailazy account.
  2. Complete Domain Authentication.
  3. Generate the Mailazy Access Key

Integrate Mailazy with PHP

Start Sending mail using the code provided below:

<?php
$curl = curl_init();
curl_setopt_array($curl, array(
    CURLOPT_URL => "https://api.mailazy.com/v1/mail/send",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => "",
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 0,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => "POST",
    CURLOPT_POSTFIELDS =>'{' .
        '"to": ["example@example.com"],' .
        '"from": "Sender <sender@example.com>",' .
        '"subject": "<Subject>",' .
        '"content": [{"type": "text/plain","value": "<Content>"}]' .
    '}',
    CURLOPT_HTTPHEADER => array(
    "X-Api-Key: <API KEY>",
    "X-Api-Secret: <API SECRET>",
    "Content-Type: application/json"
    ),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
?>