Send Email

post
Send Email

https://api.saino.io/api/apis/email/send
This endpoint allows you to send an email.
Request
Response
Request
Headers
Authorization
required
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
Body Parameters
to
required
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
required
string
This contains email subject
from
required
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
required
string
Display name for from email address
bodyHtml
optional
string
This field used to send html content in email either bodyHtml or bodyText is required
bodyText
optional
string
This field used to send normal text content in email either bodyHtml or bodyText is required
trackClicks
optional
boolean
Should the click be tracked? If no value has been provided, Account's default setting will be used.
trackOpens
optional
boolean
Should the opens be tracked? If no value has been provided, Account's default setting will be used
replyToEmail
optional
string
Email address to reply to
replyToName
optional
string
Name to replay to name
attachments
optional
array
An array of ID's of attachments. Note: you can get attachment id from uploading attachment by upload attachment API
callbackUrl
optional
string
Call back where you received notifications related to email.
Response
200: OK
Cake successfully retrieved.
{
status: true,
message: "Success",
campaignId:"8asd6sx-as6tasvdt-asdg532v"
}
400: Bad Request
Whenever some fields missings or invalid values present.
{
status: false,
error: "Some required fields missings"
}
401: Unauthorized
Whener ver user access with invalid authorasation key.
{
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

NodeJs
PHP
Python
C
C#
HTTP
JAVA
SWIFT
NodeJs
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
<?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;
Python
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'))
C
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);
C#
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);
HTTP
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"
}
JAVA
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();
SWIFT
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()