Copiedcurl -X POST \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
"https://api.zeptomail.com/v1.1/mc/email" \
-H "Authorization: <send mail token>" \
-d '{
"headers" : {
"key" : "headers"
},
"personalizations" : [ {
"cc" : [ {
"name" : "name",
"email" : "email"
} ],
"bcc" : [ {
"name" : "name",
"email" : "email"
} ],
"to" : [ {
"name" : "name",
"email" : "email"
} ]
} ],
"from" : {
"name":"name",
"email":"email"
},
"subject" : "subject",
"content" : [ {
"type" : "text",
"value" : "value"
} ]
}'
Copiedimport java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import org.json.JSONObject;
public class JavaSendapi {
public static void main(String[] args) throws Exception {
String postUrl = "https://api.zeptomail.com/v1.1/mc/email";
BufferedReader br = null;
HttpURLConnection conn = null;
String output = null;
StringBuffer sb = new StringBuffer();
try {
URL url = new URL(postUrl);
conn = (HttpURLConnection) url.openConnection();
conn.setDoOutput(true);
conn.setRequestMethod("POST");
conn.setRequestProperty("Content-Type", "application/json");
conn.setRequestProperty("Accept", "application/json");
conn.setRequestProperty("Authorization", "<send_mail_token>");
JSONObject object = new JSONObject("{
\"headers\" : { \"<key>\" : \"<headers>\" },
\"from\": { \"email\": \"<fromName>\", \"name\": \"<fromAddress@example.com>\" },
\"personalizations\" : [ {
\"cc\" : [ { \"name\" : \"<ccName>\", \"email\" : \"<ccAddress@example.com>\" } ],
\"bcc\" : [ { \"name\" : \"<bccName>\", \"email\" : \"<bccAddress@example.com>\" } ],
\"to\" : [ { \"name\" : \"<toName>\", \"email\" : \"<toAddress@example.com>\" } ] } ],
\"subject\" : \"Test subject\",
\"content\" : [ { \"type\" : \"<html/text>\", \"value\" : \"<This is a test email>\" } ],
\"reply_to\" : { \"email\": \"<replyToName>\", \"name\": \"<replyToAddress@example.com>\" }
}");
OutputStream os = conn.getOutputStream();
os.write(object.toString().getBytes());
os.flush();
br = new BufferedReader(new InputStreamReader((conn.getInputStream())));
while ((output = br.readLine()) != null) {
sb.append(output);
}
System.out.println(sb.toString());
} catch (Exception e) {
br = new BufferedReader(new InputStreamReader((conn.getErrorStream())));
while ((output = br.readLine()) != null) {
sb.append(output);
}
System.out.println(sb.toString());
} finally {
try {
if (br != null) {
br.close();
}
} catch (Exception e) {
e.printStackTrace();
}
try {
if (conn != null) {
conn.disconnect();
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
Copiedimport requests
url = "https://api.zeptomail.com/v1.1/mc/email"
payload = "{ \"headers\" : { \"<key>\" : \"<headers>\" }, \"from\": { \"email\": \"<fromName>\", \"name\": \"<fromAddress@example.com>\" }, \"personalizations\" : [ { \"cc\" : [ { \"name\" : \"<ccName>\", \"email\" : \"<ccAddress@example.com>\" } ], \"bcc\" : [ { \"name\" : \"<bccName>\", \"email\" : \"<bccAddress@example.com>\" } ], \"to\" : [ { \"name\" : \"<toName>\", \"email\" : \"<toAddress@example.com>\" } ] } ], \"subject\" : \"Test subject\", \"content\" : [ { \"type\" : \"<html/text>\", \"value\" : \"<This is a test email>\" } ], \"reply_to\" : { \"email\": \"<replyToName>\", \"name\": \"<replyToAddress@example.com>\" } }"
headers = {
'accept': "application/json",
'content-type': "application/json",
'authorization': "<send_mail_token>",
}
response = requests.request("POST", url, data=payload, headers=headers)
print(response.text)
Copied<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.zeptomail.com/v1.1/mc/email",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => '{
"headers": {
"<key>": "<headers>"
},
"from": {
"email": "<fromName>",
"name": "<fromAddress@example.com>"
},
"personalizations": [
{
"cc": [
{
"name": "<ccName>",
"email": "<ccAddress@example.com>"
}
],
"bcc": [
{
"name": "<bccName>",
"email": "<bccAddress@example.com>"
}
],
"to": [
{
"name": "<toName>",
"email": "<toAddress@example.com>"
}
]
}
],
"subject": "Test subject",
"content": [
{
"type": "<html/text>",
"value": "<This is a test email>"
}
],
"reply_to": {
"email": "<replyToName>",
"name": "<replyToAddress@example.com>"
}
}'
CURLOPT_HTTPHEADER => array(
"accept: application/json",
"authorization: <send_mail_token>",
"cache-control: no-cache",
"content-type: application/json",
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
?>
Copiedusing System;
using System.Net;
using System.Text;
using System.IO;
using System.Net.Http;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
namespace Rextester
{
public class Program
{
public static void Main(string[] args)
{
System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12;
var baseAddress = "https://api.zeptomail.com/v1.1/mc/email";
var http = (HttpWebRequest)WebRequest.Create(new Uri(baseAddress));
http.Accept = "application/json";
http.ContentType = "application/json";
http.Method = "POST";
http.PreAuthenticate = true;
http.Headers.Add("Authorization", "<send_mail_token>");
JObject parsedContent = JObject.Parse("{
'headers' : {
'<key>' : '<headers>'
},
'from': {
'email': '<fromName>',
'name': '<fromAddress@example.com>'
},
'personalizations' : [ {
'cc' : [ {
'name' : '<ccName>',
'email' : '<ccAddress@example.com>'
} ],
'bcc' : [ {
'name' : '<bccName>',
'email' : '<bccAddress@example.com>'
} ],
'subject' : 'Test subject',
'to' : [ {
'name' : '<toName>',
'email' : '<toAddress@example.com>'
} ]
} ],
'content' : [ {
'type' : '<html/text>',
'value' : '<This is a test email>'
} ],
'reply_to' : {
'email': '<replyToName>',
'name': '<replyToAddress@example.com>'
}
}");
Console.WriteLine (parsedContent.ToString());
ASCIIEncoding encoding = new ASCIIEncoding();
Byte[] bytes = encoding.GetBytes(parsedContent.ToString());
Stream newStream = http.GetRequestStream();
newStream.Write(bytes, 0, bytes.Length);
newStream.Close();
var response = http.GetResponse();
var stream = response.GetResponseStream();
var sr = new StreamReader(stream);
var content = sr.ReadToEnd();
Console.WriteLine (content);
}
}
}