sendPost
Send a message over MailChannels API
click-tracking notes: * if the URL of the 'a' tag is empty within the HTML body or doesn't start with http/https, or has a clicktracking attribute with a value of 'off', it will be ignored.
/send
Usage and SDK Samples
curl -X POST \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
"https://api.mailchannels.net/tx/v1/send?dry-run=true" \
-d '{
"headers" : {
"key" : "headers"
},
"personalizations" : [ {
"cc" : [ {
"name" : "name",
"email" : "email"
} ],
"headers" : {
"key" : "headers"
},
"bcc" : [ {
"name" : "name",
"email" : "email"
} ],
"reply_to" : {
"name" : "name",
"email" : "email"
},
"dkim_domain" : "dkim_domain",
"subject" : "subject",
"dkim_private_key" : "dkim_private_key",
"dynamic_template_data" : "{}",
"from" : {
"name" : "name",
"email" : "email"
},
"to" : [ {
"name" : "name",
"email" : "email"
} ],
"dkim_selector" : "dkim_selector"
} ],
"attachments" : [ {
"filename" : "filename",
"type" : "type",
"content" : "content"
} ],
"reply_to" : {
"name" : "name",
"email" : "email"
},
"tracking_settings" : {
"click_tracking" : {
"enable" : false
},
"open_tracking" : {
"enable" : false
}
},
"subject" : "subject",
"from" : {
"name" : "name",
"email" : "email"
},
"mailfrom" : {
"name" : "name",
"email" : "email"
},
"content" : [ {
"template_type" : "mustache",
"type" : "type",
"value" : "value"
} ]
}'
import org.openapitools.client.*;
import org.openapitools.client.auth.*;
import org.openapitools.client.model.*;
import org.openapitools.client.api.DefaultApi;
import java.io.File;
import java.util.*;
public class DefaultApiExample {
public static void main(String[] args) {
// Create an instance of the API class
DefaultApi apiInstance = new DefaultApi();
String xApiKey = xApiKey_example; // String |
MailSendBody mailSendBody = ; // MailSendBody |
Boolean dryRun = true; // Boolean | When present and set to true, the message will not be sent. Instead, the fully rendered
message is returned. This can be useful for testing.
try {
Message result = apiInstance.sendPost(xApiKey, mailSendBody, dryRun);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling DefaultApi#sendPost");
e.printStackTrace();
}
}
}
import org.openapitools.client.api.DefaultApi;
public class DefaultApiExample {
public static void main(String[] args) {
DefaultApi apiInstance = new DefaultApi();
String xApiKey = xApiKey_example; // String |
MailSendBody mailSendBody = ; // MailSendBody |
Boolean dryRun = true; // Boolean | When present and set to true, the message will not be sent. Instead, the fully rendered
message is returned. This can be useful for testing.
try {
Message result = apiInstance.sendPost(xApiKey, mailSendBody, dryRun);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling DefaultApi#sendPost");
e.printStackTrace();
}
}
}
// Create an instance of the API class
DefaultApi *apiInstance = [[DefaultApi alloc] init];
String *xApiKey = xApiKey_example; // (default to null)
MailSendBody *mailSendBody = ; //
Boolean *dryRun = true; // When present and set to true, the message will not be sent. Instead, the fully rendered
message is returned. This can be useful for testing.
(optional) (default to null)
// Send a message over MailChannels API
[apiInstance sendPostWith:xApiKey
mailSendBody:mailSendBody
dryRun:dryRun
completionHandler: ^(Message output, NSError* error) {
if (output) {
NSLog(@"%@", output);
}
if (error) {
NSLog(@"Error: %@", error);
}
}];
var EmailApi = require('email_api');
// Create an instance of the API class
var api = new EmailApi.DefaultApi()
var xApiKey = xApiKey_example; // {String}
var mailSendBody = ; // {MailSendBody}
var opts = {
'dryRun': true // {Boolean} When present and set to true, the message will not be sent. Instead, the fully rendered
message is returned. This can be useful for testing.
};
var callback = function(error, data, response) {
if (error) {
console.error(error);
} else {
console.log('API called successfully. Returned data: ' + data);
}
};
api.sendPost(xApiKey, mailSendBody, opts, callback);
using System;
using System.Diagnostics;
using Org.OpenAPITools.Api;
using Org.OpenAPITools.Client;
using Org.OpenAPITools.Model;
namespace Example
{
public class sendPostExample
{
public void main()
{
// Create an instance of the API class
var apiInstance = new DefaultApi();
var xApiKey = xApiKey_example; // String | (default to null)
var mailSendBody = new MailSendBody(); // MailSendBody |
var dryRun = true; // Boolean | When present and set to true, the message will not be sent. Instead, the fully rendered
message is returned. This can be useful for testing.
(optional) (default to null)
try {
// Send a message over MailChannels API
Message result = apiInstance.sendPost(xApiKey, mailSendBody, dryRun);
Debug.WriteLine(result);
} catch (Exception e) {
Debug.Print("Exception when calling DefaultApi.sendPost: " + e.Message );
}
}
}
}
<?php
require_once(__DIR__ . '/vendor/autoload.php');
// Create an instance of the API class
$api_instance = new OpenAPITools\Client\Api\DefaultApi();
$xApiKey = xApiKey_example; // String |
$mailSendBody = ; // MailSendBody |
$dryRun = true; // Boolean | When present and set to true, the message will not be sent. Instead, the fully rendered
message is returned. This can be useful for testing.
try {
$result = $api_instance->sendPost($xApiKey, $mailSendBody, $dryRun);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling DefaultApi->sendPost: ', $e->getMessage(), PHP_EOL;
}
?>
use Data::Dumper;
use WWW::OPenAPIClient::Configuration;
use WWW::OPenAPIClient::DefaultApi;
# Create an instance of the API class
my $api_instance = WWW::OPenAPIClient::DefaultApi->new();
my $xApiKey = xApiKey_example; # String |
my $mailSendBody = WWW::OPenAPIClient::Object::MailSendBody->new(); # MailSendBody |
my $dryRun = true; # Boolean | When present and set to true, the message will not be sent. Instead, the fully rendered
message is returned. This can be useful for testing.
eval {
my $result = $api_instance->sendPost(xApiKey => $xApiKey, mailSendBody => $mailSendBody, dryRun => $dryRun);
print Dumper($result);
};
if ($@) {
warn "Exception when calling DefaultApi->sendPost: $@\n";
}
from __future__ import print_statement
import time
import openapi_client
from openapi_client.rest import ApiException
from pprint import pprint
# Create an instance of the API class
api_instance = openapi_client.DefaultApi()
xApiKey = xApiKey_example # String | (default to null)
mailSendBody = # MailSendBody |
dryRun = true # Boolean | When present and set to true, the message will not be sent. Instead, the fully rendered
message is returned. This can be useful for testing.
(optional) (default to null)
try:
# Send a message over MailChannels API
api_response = api_instance.send_post(xApiKey, mailSendBody, dryRun=dryRun)
pprint(api_response)
except ApiException as e:
print("Exception when calling DefaultApi->sendPost: %s\n" % e)
extern crate DefaultApi;
pub fn main() {
let xApiKey = xApiKey_example; // String
let mailSendBody = ; // MailSendBody
let dryRun = true; // Boolean
let mut context = DefaultApi::Context::default();
let result = client.sendPost(xApiKey, mailSendBody, dryRun, &context).wait();
println!("{:?}", result);
}
Scopes
Parameters
Header parameters
Name | Description |
---|---|
X-Api-Key* |
String
Required
|
Body parameters
Name | Description |
---|---|
mailSendBody * |
Query parameters
Name | Description |
---|---|
dry-run |
Boolean
When present and set to true, the message will not be sent. Instead, the fully rendered
message is returned. This can be useful for testing.
|