Send Email
curl --request POST \
--url https://api.mailofly.com/api/emails \
--header 'Authorization: <authorization>' \
--header 'Content-Type: application/json' \
--data '
{
"from": "<string>",
"to": [
"<string>"
],
"subject": "<string>",
"html": "<string>",
"text": "<string>",
"template_id": "<string>",
"variables": {}
}
'import requests
url = "https://api.mailofly.com/api/emails"
payload = {
"from": "<string>",
"to": ["<string>"],
"subject": "<string>",
"html": "<string>",
"text": "<string>",
"template_id": "<string>",
"variables": {}
}
headers = {
"Authorization": "<authorization>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<authorization>', 'Content-Type': 'application/json'},
body: JSON.stringify({
from: '<string>',
to: ['<string>'],
subject: '<string>',
html: '<string>',
text: '<string>',
template_id: '<string>',
variables: {}
})
};
fetch('https://api.mailofly.com/api/emails', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.mailofly.com/api/emails",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'from' => '<string>',
'to' => [
'<string>'
],
'subject' => '<string>',
'html' => '<string>',
'text' => '<string>',
'template_id' => '<string>',
'variables' => [
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.mailofly.com/api/emails"
payload := strings.NewReader("{\n \"from\": \"<string>\",\n \"to\": [\n \"<string>\"\n ],\n \"subject\": \"<string>\",\n \"html\": \"<string>\",\n \"text\": \"<string>\",\n \"template_id\": \"<string>\",\n \"variables\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<authorization>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.mailofly.com/api/emails")
.header("Authorization", "<authorization>")
.header("Content-Type", "application/json")
.body("{\n \"from\": \"<string>\",\n \"to\": [\n \"<string>\"\n ],\n \"subject\": \"<string>\",\n \"html\": \"<string>\",\n \"text\": \"<string>\",\n \"template_id\": \"<string>\",\n \"variables\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.mailofly.com/api/emails")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<authorization>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"from\": \"<string>\",\n \"to\": [\n \"<string>\"\n ],\n \"subject\": \"<string>\",\n \"html\": \"<string>\",\n \"text\": \"<string>\",\n \"template_id\": \"<string>\",\n \"variables\": {}\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"from": "<string>",
"to": [
"<string>"
],
"created_at": "<string>"
}Sending
Send Email
Send a transactional email.
POST
/
api
/
emails
Send Email
curl --request POST \
--url https://api.mailofly.com/api/emails \
--header 'Authorization: <authorization>' \
--header 'Content-Type: application/json' \
--data '
{
"from": "<string>",
"to": [
"<string>"
],
"subject": "<string>",
"html": "<string>",
"text": "<string>",
"template_id": "<string>",
"variables": {}
}
'import requests
url = "https://api.mailofly.com/api/emails"
payload = {
"from": "<string>",
"to": ["<string>"],
"subject": "<string>",
"html": "<string>",
"text": "<string>",
"template_id": "<string>",
"variables": {}
}
headers = {
"Authorization": "<authorization>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<authorization>', 'Content-Type': 'application/json'},
body: JSON.stringify({
from: '<string>',
to: ['<string>'],
subject: '<string>',
html: '<string>',
text: '<string>',
template_id: '<string>',
variables: {}
})
};
fetch('https://api.mailofly.com/api/emails', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.mailofly.com/api/emails",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'from' => '<string>',
'to' => [
'<string>'
],
'subject' => '<string>',
'html' => '<string>',
'text' => '<string>',
'template_id' => '<string>',
'variables' => [
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.mailofly.com/api/emails"
payload := strings.NewReader("{\n \"from\": \"<string>\",\n \"to\": [\n \"<string>\"\n ],\n \"subject\": \"<string>\",\n \"html\": \"<string>\",\n \"text\": \"<string>\",\n \"template_id\": \"<string>\",\n \"variables\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<authorization>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.mailofly.com/api/emails")
.header("Authorization", "<authorization>")
.header("Content-Type", "application/json")
.body("{\n \"from\": \"<string>\",\n \"to\": [\n \"<string>\"\n ],\n \"subject\": \"<string>\",\n \"html\": \"<string>\",\n \"text\": \"<string>\",\n \"template_id\": \"<string>\",\n \"variables\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.mailofly.com/api/emails")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<authorization>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"from\": \"<string>\",\n \"to\": [\n \"<string>\"\n ],\n \"subject\": \"<string>\",\n \"html\": \"<string>\",\n \"text\": \"<string>\",\n \"template_id\": \"<string>\",\n \"variables\": {}\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"from": "<string>",
"to": [
"<string>"
],
"created_at": "<string>"
}Dispatches a single transactional email to one or more recipients.
Headers
string
required
Bearer token formatted as
Bearer mfly_live_...Body
string
required
Sender address, e.g.
Acme <hello@acme.com>. Must match a verified domain.string[]
required
List of recipient email addresses (up to 50).
string
required
Email subject line.
string
HTML message body.
string
Plaintext fallback message.
string
Optional ID or slug of a pre-configured template.
object
Key-value dictionary of dynamic merge variables.
Response
string
Unique message identifier (
msg_...).string
Sender address used.
string[]
Recipient addresses.
string
ISO-8601 timestamp.
⌘I