Method: POST
Endpoint: /api/sendEmail
Parameter | Type | Required |
Description |
recipient | Yes | Email of contact to whom to you want to send email | |
from_email | Yes | From email | |
bounce_email | string | Yes | Return path where the failed delivery reports will be send |
from_name | string | Yes | From name |
body | string | Yes | Body of email content |
subject | string | Yes | Email subject |
node_id | string | Yes | Sending node id of node you want to use for sending email |
add_contact | integer (1) | No | Pass 1 to add contact to any list |
list_id | integer | No | List id of the list in which you want to add contact |
Parameter | Type | Description |
status | JSON | Success or Error |
result | JSON | Result of the operation |
<?php
// Authentication
$api_token = 'API_KEY'; // Mumara API Key (can be found in Settings -> API Key)
$domain = 'http://www.anydomain.com'; // Your Mumara Domain Name
// API Endpoint
$endpoint = '/api/sendEmail';
$params = [
'recipient' => '[email protected]',
'from_email' => '[email protected]',
'from_name' => 'Rachel',
'body' => 'This is Test Email',
'subject' => 'Test Subject',
'bounce_email' => '[email protected]',
'node_id' => '30',
//'add_contact' => '1',
//'list_id' => '90',
];
// Defining cURL Request
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$domain.$endpoint);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params));
curl_setopt($ch, CURLOPT_HTTPHEADER,
array('Content-Type: application/json', 'Authorization: Bearer ' . $api_token));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Executing cURL
$output = curl_exec ($ch);
// Printing Output
echo "<pre>";
echo json_encode(json_decode($output),JSON_PRETTY_PRINT );
// Closing cURL
curl_close ($ch);
?>
{
"status": "error",
"0": "result",
"1": {
"recipient": [
"Error: Missing required parameter, recipient"
],
"from_email": [
"Error: Missing required parameter, from email"
],
"bounce_email": [
"Error: Missing required parameter, bounce email"
],
"from_name": [
"Error: Missing required parameter, from name"
],
"body": [
"Error: Missing required parameter, body"
],
"subject": [
"Error: Missing required parameter, subject"
],
"node_id": [
"Error: Missing required parameter, node id"
]
}
}
Status value of the success response will be "success"
{
"status": "success",
"result": {
"email": "[email protected]",
"response": "Sent"
}
}