Knowledgebase

Send Email APi

There are list of actions that you can perform by programmatically accessing the application. You can manage lists, contacts, campaigns and can now even send emails using the APi discussed that is discussed in this article. This would help create a content for the campaign, style it and send it to one or multiple contacts.

Required to Submit Request 

Username

The email that account holder uses to login MumaraClassic

API Token

The API token user has generated using API Configuration section of MumaraClassic, also mentioned above.

Method

Method being called (Post)

Path

Path to the API file being called ('http//www.yourdomain.com/API/sendEmail)

Required Parameter 

smtp_username

Requires username of the SMTP you want to send this email from. This would belong to one of the SMTPs you have configured your system (MumaraClassic) with. 

subject 

Subject is the mandatory parameter to fill with the subject line of the email

from_name

From_name is required as part of sender information. For this parameter, provide a from name to send your email email from. 

from_email

An email to send this email from is also mandatory to submit a valid APi request. 

reply_email 

Provide an email address to send replies at. As part of From/Sender information, if isn't set as reply_email = from_email , you would need to provide a reply_email as mandatory parameter. 

content 

Content of your email in this mandatory parameter, you can add styling option as you can see in the following sample APi request. 

Optional 

custom_header

You can use this parameter as option, only if you are looking to add some additional value within email header. The sample request in the following area has this field used. 

message_id

Another optional parameter that you can use to add desired message_id value in the email header. Value for this parameter in the APi request should be added with @ like in the following sample request. In the result of adding this parameter in the APi call, you will get the desired message_id value added in the email header. The message header will include a random string combined with the value you added in the APi call with @. For the message id in the header it is how the value will appear, Message_ID<abc123654>@yahoo.net. 

Note: If you don't use this optional parameter of message_id in the APi call, even then Mumara generates a message ID and includes it in the email header. This option is only given if you are looking to add a desired value of the message ID in the header.

Sample Request

<?php
$postData = array(
    'to' => array('[email protected]','[email protected]'),
    'smtp_username' => 'Your SMTP Username',
    'subject' => 'This Test Email',
    'custom_headers' => array('header_1' => 'list_unsub','header_2' => 'value_2'),
    'from_name' => 'Sender',
    'from_email' => '[email protected]',
    'reply_email' => '[email protected]',
    'message_id' => '@yahoo.net',
    'content' => '<div><p style="color:red;">This is text content body (body)</p><button>test button</button> </div>'
);

$postData = json_encode($postData);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://yourdomain.com/API/sendEmail');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
curl_setopt($ch, CURLOPT_POSTFIELDS, array('data' => $postData));
curl_setopt($ch, CURLOPT_HTTPHEADER,
    array('APIToken: 343b1b831067b50e308e6bf93e0f06f0', 'Login: [email protected]'));

$data = curl_exec($ch);
if (curl_errno($ch)) {
    print "Error: " . curl_error($ch);
    curl_close($ch);
} else {
    print ($data);
    curl_close($ch);
}
?>

Success Response

A text based response with "Success" status will be returned upon submitting a request with right parameters, valid end point and API key. The text based message would show the number of emails to which the message has successfully been sent, i.e. 

{"status":"success","response":"Email has been sent to 2 Subscribers out of 2"}

If there is only one contact to which APi call has attempted to send, then the response will return the contact's email as well, i.e.

{"status":"success","response":"Email has been sent to [email protected]"}

Erroneous Response

A text based response providing the reason of the error. i.e.