curl -X POST 'https://api.mailram.com/v1/emails' \
-H 'Authorization: Bearer API_KEY' \
-H 'Content-Type: application/json' \
-d $'{
"from": "Acme <[email protected]>",
"to": ["[email protected]"],
"subject": "hello world",
"html": "<p>it works!</p>",
"text": "it works!",
"attachments": [
{
"filename": "invoice.pdf",
"url": "https://s3.aws/invoice.pdf",
},
]
}'
import fetch from 'node-fetch';
fetch('https://api.mailram.com/v1/emails', {
method: 'POST',
headers: {
'Authorization': 'Bearer API_KEY',
'Content-Type': 'application/json'
},
body: '{
"from": "Acme <[email protected]>",
"to": ["[email protected]"],
"subject": "hello world",
"html": "<p>it works!</p>",
"text": "it works!",
"attachments": [
{
"filename": "invoice.pdf",
"url": "https://s3.aws/invoice.pdf",
},
]
}'
});
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.mailram.com/v1/emails');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer API_KEY',
'Content-Type: application/json',
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, "{
"from": "Acme <[email protected]>",
"to": ["[email protected]"],
"subject": "hello world",
"html": "<p>it works!</p>",
"text": "it works!",
"attachments": [
{
"filename": "invoice.pdf",
"url": "https://s3.aws/invoice.pdf",
},
]
}");
$response = curl_exec($ch);
curl_close($ch);
require 'net/http'
uri = URI('https://api.mailram.com/v1/emails')
req = Net::HTTP::Post.new(uri)
req.content_type = 'application/json'
req['Authorization'] = 'Bearer API_KEY'
req.body = "{
"from": "Acme <[email protected]>",
"to": ["[email protected]"],
"subject": "hello world",
"html": "<p>it works!</p>",
"text": "it works!",
"attachments": [
{
"filename": "invoice.pdf",
"url": "https://s3.aws/invoice.pdf",
},
]
}"
req_options = {
use_ssl: uri.scheme == 'https'
}
res = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http|
http.request(req)
end
using System.Net.Http;
using System.Net.Http.Headers;
HttpClient client = new HttpClient();
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, "https://api.mailram.com/v1/emails");
request.Headers.Add("Authorization", "Bearer API_KEY");
request.Content = new StringContent("{
"from": "Acme <[email protected]>",
"to": ["[email protected]"],
"subject": "hello world",
"html": "<p>it works!</p>",
"text": "it works!",
"attachments": [
{
"filename": "invoice.pdf",
"url": "https://s3.aws/invoice.pdf",
},
]
}");
request.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
HttpResponseMessage response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
string responseBody = await response.Content.ReadAsStringAsync();
package main
import (
"fmt"
"io"
"log"
"net/http"
"strings"
)
func main() {
client := &http.Client{}
var data = strings.NewReader("
{
"from": "Acme <[email protected]>",
"to": ["[email protected]"],
"subject": "hello world",
"html": "<p>it works!</p>",
"text": "it works!",
"attachments": [
{
"filename": "invoice.pdf",
"url": "https://s3.aws/invoice.pdf",
},
]
}
")
req, err := http.NewRequest("POST", "https://api.mailram.com/v1/emails", data)
if err != nil {
log.Fatal(err)
}
req.Header.Set("Authorization", "Bearer API_KEY")
req.Header.Set("Content-Type", "application/json")
resp, err := client.Do(req)
if err != nil {
log.Fatal(err)
}
defer resp.Body.Close()
bodyText, err := io.ReadAll(resp.Body)
if err != nil {
log.Fatal(err)
}
fmt.Printf("%s
", bodyText)
}
import java.io.IOException;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpRequest.BodyPublishers;
import java.net.http.HttpResponse;
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.mailram.com/v1/emails"))
.POST(BodyPublishers.ofString("{
"from": "Acme <[email protected]>",
"to": ["[email protected]"],
"subject": "hello world",
"html": "<p>it works!</p>",
"text": "it works!",
"attachments": [
{
"filename": "invoice.pdf",
"url": "https://s3.aws/invoice.pdf",
},
]
}"))
.setHeader("Authorization", "Bearer API_KEY")
.setHeader("Content-Type", "application/json")
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
import requests
headers = {
'Authorization': 'Bearer API_KEY',
'Content-Type': 'application/json',
}
data = '{
"from": "Acme <[email protected]>",
"to": ["[email protected]"],
"subject": "hello world",
"html": "<p>it works!</p>",
"text": "it works!",
"attachments": [
{
"filename": "invoice.pdf",
"url": "https://s3.aws/invoice.pdf",
},
]
}'
response = requests.post('https://api.mailram.com/v1/emails', headers=headers, data=data)