Skip to content

Senders Calls

Introduction

Senders represent sender addresses or domains which have been validated on Mailjet's system to send transactional emails. The Mailjet resource matching the senders Mandrill resource is sender.

List

Info

Maps to /senders/list.json

<?php
require 'vendor/autoload.php';
use \Mailjet\Resources;
$mj = new \Mailjet\Client(getenv('MJ_APIKEY_PUBLIC'), getenv('MJ_APIKEY_PRIVATE'));
$response = $mj->get(Resources::$Sender);
$response->success() && var_dump($response->getData());
?>
{
  "Count": 1,
  "Data": [
    {
      "CreatedAt": "2015-09-07T06:59:52Z",
      "DNSID": "1",
      "Email": "anothersender@example.com",
      "EmailType": "unknown",
      "Filename": "0123456789abcdef.txt",
      "ID": "1",
      "IsDefaultSender": "false",
      "Name": "Myname",
      "Status": "Inactive"
    }
  ],
  "Total": 1
}

Issue a GET request on the sender resource.

Domains

Info

Maps to /senders/domains.json

The senders domains are included in the sender resource. A sender domain is represented in the form of "*@domain.com".

Add-Domain

Info

Maps to /senders/add-domain.json

<?php
require 'vendor/autoload.php';
use \Mailjet\Resources;
$mj = new \Mailjet\Client(getenv('MJ_APIKEY_PUBLIC'), getenv('MJ_APIKEY_PRIVATE'));
$response = $mj->get(Resources::$Dns);
$response->success() && var_dump($response->getData());
?>
{
  "Count": 1,
  "Data": [
    {
      "DKIMRecordName": "",
      "DKIMRecordValue": "",
      "DKIMStatus": "",
      "Domain": "",
      "ID": "",
      "IsCheckInProgress": "false",
      "LastCheckAt": "",
      "OwnerShipToken": "",
      "OwnerShipTokenRecordName": "",
      "SPFRecordValue": "",
      "SPFStatus": ""
    }
  ],
  "Total": 1
}

Everytime you post a new sender (address or domain) which doesn't map to an existing domain in the Mailjet system, a new dns resource is created. You can then issue GET request on this request, using the ID or the domain name. The dns resource provides you with all the information you need to setup your domain in a valid way to start sending using a related sender address or domain.

Check-Domain

Info

Maps to /senders/check-domain.json

<?php
require 'vendor/autoload.php';
use \Mailjet\Resources;
$mj = new \Mailjet\Client(getenv('MJ_APIKEY_PUBLIC'), getenv('MJ_APIKEY_PRIVATE'));
$response = $mj->post(Resources::$DnsCheck, ['id' => $id]);
$response->success() && var_dump($response->getData());
?>
{
  "Count": 1,
  "Data": [
    {
      "DKIMErrors": ["no DKIM record"],
      "DKIMRecordCurrentValue": "",
      "DKIMStatus": "Error",
      "SPFErrors": [],
      "SPFRecordsCurrentValues": ["v=spf1 include:spf.mailjet.com -all"],
      "SPFStatus": "OK"
    }
  ],
  "Total": 1
}

To check the configuration of a given domain, issue a POST request on dns/:id/check resource. This action checks if the DNS configuration for SPF and DKIM records matches the expected configuration from Mailjet.

Verify-Domain

Info

Maps to /senders/verify-domain.json

<?php
require 'vendor/autoload.php';
use \Mailjet\Resources;
$mj = new \Mailjet\Client(getenv('MJ_APIKEY_PUBLIC'), getenv('MJ_APIKEY_PRIVATE'));
$response = $mj->post(Resources::$SenderValidate, ['id' => $id]);
$response->success() && var_dump($response->getData());
?>
{
  "Count": 1,
  "Data": [
    {
      "Errors": {
        "DNSValidationError": " DNS record verification failed as no TXT record for that ownership token was found on the remote server.",
        "FileValidationError": " File verification failed as ecff63dc3593b2323b5ab3d7d823c103.txt cannot be found at domain root."
      },
      "GlobalError": "Neither the file at your domain root nor the DNS TXT record have been found to validate this sender.",
      "ValidationMethod": ""
    }
  ],
  "Total": 1
}

Once you cleared out your DNS configuration, you can validate the related sender.

Info

Info

Maps to /senders/info.json

<?php
require 'vendor/autoload.php';
use \Mailjet\Resources;
$mj = new \Mailjet\Client(getenv('MJ_APIKEY_PUBLIC'), getenv('MJ_APIKEY_PRIVATE'));
$response = $mj->get(Resources::$Sender);
$response->success() && var_dump($response->getData());
?>
{
  "Count": 1,
  "Data": [
    {
      "CreatedAt": "2015-09-07T06:59:52Z",
      "DNSID": "1",
      "Email": "anothersender@example.com",
      "EmailType": "unknown",
      "Filename": "0123456789abcdef.txt",
      "ID": "1",
      "IsDefaultSender": "false",
      "Name": "Myname",
      "Status": "Inactive"
    }
  ],
  "Total": 1
}

Issue a GET request to the sender resource with the associated ID.

Time-Series

Info

Maps to /senders/time-series.json

<?php
require 'vendor/autoload.php';
use \Mailjet\Resources;
$mj = new \Mailjet\Client(getenv('MJ_APIKEY_PUBLIC'), getenv('MJ_APIKEY_PRIVATE'));
$response = $mj->get(Resources::$Senderstatistics);
$response->success() && var_dump($response->getData());
?>
{
  "Count": 1,
  "Data": [
    {
      "BlockedCount": "",
      "BouncedCount": "",
      "ClickedCount": "",
      "DeliveredCount": "",
      "LastActivityAt": "",
      "OpenedCount": "",
      "ProcessedCount": "",
      "QueuedCount": "",
      "SenderID": "",
      "SpamComplaintCount": "",
      "UnsubscribedCount": ""
    }
  ],
  "Total": 1
}

Use the statcounters resource to retrieve all the main information you need. To get sender stats, make sure to set the value of the CounterSource filter to Sender and the SourceID filter to the respective sender ID.