Saino
  • Getting Started
  • Security & Authentication
  • Base URL Setting
  • SDKs & Plugins
  • SMS api
    • Overview
    • Send SMS
    • Send SMS (POST API)
    • Confidential SMS
  • Voice API
    • Overview
    • Send Voice Call
    • Scheduled Voice Setting
    • Voice Language
  • EMAIL API
    • Overview
    • Send Email
    • Upload Attachment
  • Email Cleaner
    • Overview
    • Single Email
    • Bulk Email
    • Bulk Email Progress / Status
  • Account API
    • Account & Balance Info
Powered by GitBook
On this page
  • Send Email
  • Callback Url response
  • Examples

Was this helpful?

  1. EMAIL API

Send Email

Send Email

POST https://api.saino.io/api/apis/email/send

This endpoint allows you to send an email.

Headers

Name
Type
Description

Authorization

string

It is a bearer authentication token to validate request coming from a valid user or not. You can get this token from Saino first account from API keys section. if you passing programmtically then follow below approach: Authorization: "Bearer " + API_KEY

Request Body

Name
Type
Description

to

array

This is to contain email ids where you need to send emails. you can add multiple email ids where you need to send emails

subject

string

This contains email subject

from

string

This is a from email id. you can assigned only verified email id. you can verify from email id from sainofirst dashboard by below-specified section. dashboard -> bulk email -> settings-> domain

fromName

string

Display name for from email address

bodyHtml

string

This field used to send html content in email either bodyHtml or bodyText is required

bodyText

string

This field used to send normal text content in email either bodyHtml or bodyText is required

trackClicks

boolean

Should the click be tracked? If no value has been provided, Account's default setting will be used.

trackOpens

boolean

Should the opens be tracked? If no value has been provided, Account's default setting will be used

replyToEmail

string

Email address to reply to

replyToName

string

Name to replay to name

attachments

array

An array of ID's of attachments. Note: you can get attachment id from uploading attachment by upload attachment API

callbackUrl

string

Call back where you received notifications related to email.

{ 
    status: true, 
    message: "Success",
    campaignId:"8asd6sx-as6tasvdt-asdg532v"
}
{ 
    status: false, 
    error: "Some required fields missings" 
}
{    
    message: "Unauthorised" 
}

Callback Url response

below is the notification response received in provided callback url related to each email id.

{
    emailId: "test@test.com",  //provided to email id
    status: "sent/opened/clicked/bounce/complaint/unsubscribed", //this is email status
    campaignId: "8asd6sx-as6tasvdt-asdg532v"  //campaign id to identify
}

Examples

var axios = require('axios');
var data = JSON.stringify(
  {
    "to":["test@gmail.com"],
    "subject":"API test 1",
    "from":"test@domain.com",
    "fromName":"sahil",
    "bodyHtml":"<h1>Test 1</h1>",
    "trackClicks":true,
    "trackOpens":true,
    "replyToEmail":"test2@domain2.com",
    "attachments":[],
    "replyToName":"sam",
    "bodyText":"Just Text Email",
    "callbackUrl":"https://domain.com/webhook"
  }
);

var config = {
  method: 'post',
  url: 'https://api.saino.io/api/apis/email/send',
  headers: { 
    'Authorization': 'Bearer 808ciij4p18351yml==/pitzkg67bizz0qce1599144457846', 
    'Content-Type': 'application/json'
  },
  data : data
};

axios(config).then(function (response) {
  console.log(JSON.stringify(response.data));
})
.catch(function (error) {
  console.log(error);
});
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://api.saino.io/api/apis/email/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 =>"{\n     \"to\":[\"test@gmail.com\"], \n     \"subject\":\"API test 1\", \n     \"from\":\"test@domain.com\", \n     \"fromName\":\"sainofirst\", \n     \"bodyHtml\":\"<h1>Test 1</h1>\", \n     \"trackClicks\":true, \n     \"trackOpens\":true, \n     \"replyToEmail\":\"test2@sainofirst.com\", \n     \"attachments\":[], \n     \"replyToName\":\"sainofirst2\", \n     \"bodyText\":\"Just Text Email\",\n     \"callbackUrl\":\"https://domain.com/webhook\"\n}",
  CURLOPT_HTTPHEADER => array(
    "Authorization: Bearer 808ciij4p1835zba8ykvkw9p==/pitzkg67bizz0qce1599144457846",
    "Content-Type: application/json"
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
import requests

url = "https://api.saino.io/api/apis/email/send"

payload = "{\n     \"to\":[\"test@gmail.com\"], \n     \"subject\":\"API test 1\", \n     \"from\":\"test@domain.com\", \n     \"fromName\":\"sainofirst\", \n     \"bodyHtml\":\"<h1>Test 1</h1>\", \n     \"trackClicks\":true, \n     \"trackOpens\":true, \n     \"replyToEmail\":\"test2@sainofirst.com\", \n     \"attachments\":[], \n     \"replyToName\":\"sainofirst2\", \n     \"bodyText\":\"Just Text Email\",\n     \"callbackUrl\":\"https://domain.com/webhook\"\n}"
headers = {
  'Authorization': 'Bearer 808ciij4p1835h8gkybgzba8ykvkw9pz0qce1599144457846',
  'Content-Type': 'application/json'
}

response = requests.request("POST", url, headers=headers, data = payload)

print(response.text.encode('utf8'))
CURL *curl;
CURLcode res;
curl = curl_easy_init();
if(curl) {
  curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "POST");
  curl_easy_setopt(curl, CURLOPT_URL, "https://api.saino.io/api/apis/email/send");
  curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
  curl_easy_setopt(curl, CURLOPT_DEFAULT_PROTOCOL, "https");
  struct curl_slist *headers = NULL;
  headers = curl_slist_append(headers, "Authorization: Bearer 808ciij4p18351v9rh8gkybgzba8ykvkw9p==/pitzkg67bizz0q99144457846");
  headers = curl_slist_append(headers, "Content-Type: application/json");
  curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
  const char *data = "{\n     \"to\":[\"test@gmail.com\"], \n     \"subject\":\"API test 1\", \n     \"from\":\"test@domain.com\", \n     \"fromName\":\"sainofirst\", \n     \"bodyHtml\":\"<h1>Test 1</h1>\", \n     \"trackClicks\":true, \n     \"trackOpens\":true, \n     \"replyToEmail\":\"test2@sainofirst.com\", \n     \"attachments\":[], \n     \"replyToName\":\"sainofirst2\", \n     \"bodyText\":\"Just Text Email\",\n     \"callbackUrl\":\"https://domain.com/webhook\"\n}";
  curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data);
  res = curl_easy_perform(curl);
}
curl_easy_cleanup(curl);
var client = new RestClient("https://api.saino.io/api/apis/email/send");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer 808ciijv9rzg5h8gkybgzba8ykvkw9p==/dsaddadasdda");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n     \"to\":[\"test@gmail.com\"], \n     \"subject\":\"API test 1\", \n     \"from\":\"test@domain.com\", \n     \"fromName\":\"sainofirst\", \n     \"bodyHtml\":\"<h1>Test 1</h1>\", \n     \"trackClicks\":true, \n     \"trackOpens\":true, \n     \"replyToEmail\":\"test2@sainofirst.com\", \n     \"attachments\":[], \n     \"replyToName\":\"sainofirst2\", \n     \"bodyText\":\"Just Text Email\",\n     \"callbackUrl\":\"https://domain.com/webhook\"\n}",  ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
POST /api/apis/email/send HTTP/1.1
Host: api.saino.io
Authorization: Bearer 808ciij4p18351ymliiznhybgzba8ykvkw9p==/qce1599144457846
Content-Type: application/json

{
     "to":["test@gmail.com"], 
     "subject":"API test 1", 
     "from":"test@domain.com", 
     "fromName":"sainofirst", 
     "bodyHtml":"<h1>Test 1</h1>", 
     "trackClicks":true, 
     "trackOpens":true, 
     "replyToEmail":"test2@sainofirst.com", 
     "attachments":[], 
     "replyToName":"sainofirst2", 
     "bodyText":"Just Text Email",
     "callbackUrl":"https://domain.com/webhook"
}
OkHttpClient client = new OkHttpClient().newBuilder()
  .build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n     \"to\":[\"test@gmail.com\"], \n     \"subject\":\"API test 1\", \n     \"from\":\"test@domain.com\", \n     \"fromName\":\"sainofirst\", \n     \"bodyHtml\":\"<h1>Test 1</h1>\", \n     \"trackClicks\":true, \n     \"trackOpens\":true, \n     \"replyToEmail\":\"test2@sainofirst.com\", \n     \"attachments\":[], \n     \"replyToName\":\"sainofirst2\", \n     \"bodyText\":\"Just Text Email\",\n     \"callbackUrl\":\"https://domain.com/webhook\"\n}");
Request request = new Request.Builder()
  .url("https://api.saino.io/api/apis/email/send")
  .method("POST", body)
  .addHeader("Authorization", "Bearer 808ciij4p183hrkv9rzg5h8gkybgzba8yasdp==/sadsd")
  .addHeader("Content-Type", "application/json")
  .build();
Response response = client.newCall(request).execute();
import Foundation

var semaphore = DispatchSemaphore (value: 0)

let parameters = "{\n     \"to\":[\"test@gmail.com\"], \n     \"subject\":\"API test 1\", \n     \"from\":\"test@domain.com\", \n     \"fromName\":\"sainofirst\", \n     \"bodyHtml\":\"<h1>Test 1</h1>\", \n     \"trackClicks\":true, \n     \"trackOpens\":true, \n     \"replyToEmail\":\"test2@sainofirst.com\", \n     \"attachments\":[], \n     \"replyToName\":\"sainofirst2\", \n     \"bodyText\":\"Just Text Email\",\n     \"callbackUrl\":\"https://domain.com/webhook\"\n}"
let postData = parameters.data(using: .utf8)

var request = URLRequest(url: URL(string: "https://api.saino.io/api/apis/email/send")!,timeoutInterval: Double.infinity)
request.addValue("Bearer 808ciij4pzba8ykvkw9p==/pitzkg99144457846", forHTTPHeaderField: "Authorization")
request.addValue("application/json", forHTTPHeaderField: "Content-Type")

request.httpMethod = "POST"
request.httpBody = postData

let task = URLSession.shared.dataTask(with: request) { data, response, error in 
  guard let data = data else {
    print(String(describing: error))
    return
  }
  print(String(data: data, encoding: .utf8)!)
  semaphore.signal()
}

task.resume()
semaphore.wait()
PreviousOverviewNextUpload Attachment

Last updated 4 years ago

Was this helpful?