Messages
Send email: whole messages from your product, or a person’s own.
An SDK signs every request with your key: Authentication. To sign one yourself, see Calling the API without an SDK.
On this page
The Receipt object
What a send answers: the message’s id, whether it went or waits, and who was left out.
Attributes
Mailset’s id for this send.
The id its message will have in the conversation once it goes.
When it goes out, in milliseconds since 1970: the time asked, or later when a limit holds it.
Why it waits past the time asked: a sending limit that clears by waiting.
True when what holds it is one of the plan’s sending limits, which Mailset support can raise.
sent: it went, or every recipient was skipped and nothing is left to do.queued: Mailset holds it and sends it atsendAt.One of
sentqueuedRecipients Mailset left out. They never get it, the others do, and there is nothing to retry. Absent when nobody was skipped.
Answered by
{
"id": "out_3f9a1c0e7b2d",
"messageId": "moc.elpmaxe@85a4d2b7e0c1a9f3",
"sendAt": 1796048940000,
"state": "sent"
}
messages.send
Send mail from one of your addresses. A reply (threadId) carries the message it answers under your text, as Gmail quotes it; quote false sends it bare.
POST/v1/messages.send
Parameters
One of your addresses.
Who it goes to, up to 100 addresses.
Default
[]. At most 100 items.Who gets a copy, up to 100 addresses.
Default
[]. At most 100 items.Who gets a copy the others don’t see, up to 100 addresses.
Default
[]. At most 100 items.The subject, on one line.
At most 998 characters.
The message’s text.
At most 5,000,000 characters.
Answering this conversation.
Seconds to hold it so it can be taken back, 0 to 120.
Default
0. From 0 to 120.Scheduled send: when, in ms since the epoch.
The draft this came from. It goes once the mail has.
texthas bold, italic, lists, quotes or links to send as formatting.Default
false.A reply carries the message it answers under the new text, added here at send time. False sends the new text alone.
Default
true.The conversation’s message this answers, for that quote: the newest that arrived unless given.
Returns
data is an object with:
Mailset’s id for this send.
The id its message will have in the conversation once it goes.
When it goes out, in milliseconds since 1970: the time asked, or later when a limit holds it.
Why it waits past the time asked: a sending limit that clears by waiting.
True when what holds it is one of the plan’s sending limits, which Mailset support can raise.
import { Mailset } from 'mailset';
// Reads MAILSET_TOKEN from the environment.
const mailset = new Mailset();
const answer = await mailset.messages.send({
from: "moc.elpmaxe@ana",
to: [
"moc.elpmaxe@airam",
],
subject: "Quote for March",
text: "Hi Maria, the quote is attached.",
});
console.log(answer);
from mailset import Mailset
# Reads MAILSET_TOKEN from the environment.
mailset = Mailset()
answer = mailset.messages.send(
{
"from": "moc.elpmaxe@ana",
"to": ["moc.elpmaxe@airam"],
"subject": "Quote for March",
"text": "Hi Maria, the quote is attached.",
}
)
print(answer)
package main
import (
"context"
"fmt"
"log"
mailset "mailset.app/go"
)
func main() {
// Reads MAILSET_TOKEN from the environment.
client, err := mailset.NewClient()
if err != nil {
log.Fatal(err)
}
ctx := context.Background()
params := &mailset.MessagesSendParams{
require 'mailset'
# Reads MAILSET_TOKEN from the environment.
mailset = Mailset::Client.new
answer = mailset.messages.send_message(
from: 'moc.elpmaxe@ana',
to: ['moc.elpmaxe@airam'],
subject: 'Quote for March',
text: 'Hi Maria, the quote is attached.'
)
p answer
<?php
require 'vendor/autoload.php';
// Reads MAILSET_TOKEN from the environment.
$mailset = new Mailset\Client();
$answer = $mailset->messages->send([
'from' => 'moc.elpmaxe@ana',
'to' => ['moc.elpmaxe@airam'],
'subject' => 'Quote for March',
'text' => 'Hi Maria, the quote is attached.',
]);
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
import app.mailset.Mailset;
import app.mailset.model.MessagesSendParams;
import app.mailset.model.SendReceipt;
import java.util.List;
// Reads MAILSET_TOKEN from the environment.
Mailset mailset = Mailset.fromEnv();
var params = MessagesSendParams.builder()
.from("moc.elpmaxe@ana")
.to(List.of("moc.elpmaxe@airam"))
.subject("Quote for March")
.text("Hi Maria, the quote is attached.")
.build();
SendReceipt answer = mailset.messages().send(params);
System.out.println(answer);
use mailset::types::MessagesSendParams;
// Reads MAILSET_TOKEN from the environment.
let mailset = mailset::Client::from_env()?;
let answer = mailset
.messages()
.send(MessagesSendParams {
from: "moc.elpmaxe@ana".into(),
to: Some(vec!["moc.elpmaxe@airam".into()]),
subject: Some("Quote for March".into()),
text: "Hi Maria, the quote is attached.".into(),
..Default::default()
})
.await?;
println!("{answer:?}");
curl https://mailset.app/v1/messages.send \
-H "Authorization: Bearer $TOKEN" \
-H "ms-time: $MS_TIME" \
-H "ms-proof: $MS_PROOF" \
-H "Content-Type: application/json" \
-d '{"input":{"from":"moc.elpmaxe@ana","to":["moc.elpmaxe@airam"],"subject":"Quote for March","text":"Hi Maria, the quote is attached."}}'
curl can’t sign a request. $TOKEN is your credential’s token, and $MS_TIME and $MS_PROOF sign this exact body: Calling the API without an SDK shows how.
mailset messages send --from moc.elpmaxe@ana --to moc.elpmaxe@airam --subject "Quote for March" --text "Hi Maria, the quote is attached."
{
"ok": true,
"data": {
"id": "out_3f9a1c0e7b2d",
"messageId": "moc.elpmaxe@85a4d2b7e0c1a9f3",
"sendAt": 1796048940000,
"held": "The day’s sending limit is reached.",
"raisable": true
}
}
messages.markUnread
Mark a conversation unread from this message on.
POST/v1/messages.markUnread
Parameters
The message’s id, from
threads get.
Returns
data is an object with:
The conversation it’s in.
import { Mailset } from 'mailset';
// Reads MAILSET_TOKEN from the environment.
const mailset = new Mailset();
const answer = await mailset.messages.markUnread({
id: "msg_91b7e4c2a6f03d58b1c4e7a9",
});
console.log(answer);
from mailset import Mailset
# Reads MAILSET_TOKEN from the environment.
mailset = Mailset()
answer = mailset.messages.mark_unread(
{"id": "msg_91b7e4c2a6f03d58b1c4e7a9"}
)
print(answer)
package main
import (
"context"
"fmt"
"log"
mailset "mailset.app/go"
)
func main() {
// Reads MAILSET_TOKEN from the environment.
client, err := mailset.NewClient()
if err != nil {
log.Fatal(err)
}
ctx := context.Background()
params := &mailset.MessagesMarkUnreadParams{
ID: "msg_91b7e4c2a6f03d58b1c4e7a9",
}
answer, err := client.Messages.MarkUnread(ctx, params)
if err != nil {
log.Fatal(err)
}
fmt.Println(answer)
}
require 'mailset'
# Reads MAILSET_TOKEN from the environment.
mailset = Mailset::Client.new
answer = mailset.messages.mark_unread(
id: 'msg_91b7e4c2a6f03d58b1c4e7a9'
)
p answer
<?php
require 'vendor/autoload.php';
// Reads MAILSET_TOKEN from the environment.
$mailset = new Mailset\Client();
$answer = $mailset->messages->markUnread([
'id' => 'msg_91b7e4c2a6f03d58b1c4e7a9',
]);
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
import app.mailset.Mailset;
import app.mailset.model.MessagesMarkUnreadParams;
import app.mailset.model.MessagesMarkUnreadResult;
// Reads MAILSET_TOKEN from the environment.
Mailset mailset = Mailset.fromEnv();
var params = MessagesMarkUnreadParams.builder()
.id("msg_91b7e4c2a6f03d58b1c4e7a9")
.build();
MessagesMarkUnreadResult answer =
mailset.messages().markUnread(params);
System.out.println(answer);
use mailset::types::MessagesMarkUnreadParams;
// Reads MAILSET_TOKEN from the environment.
let mailset = mailset::Client::from_env()?;
let answer = mailset
.messages()
.mark_unread(MessagesMarkUnreadParams {
id: "msg_91b7e4c2a6f03d58b1c4e7a9".into(),
})
.await?;
println!("{answer:?}");
curl https://mailset.app/v1/messages.markUnread \
-H "Authorization: Bearer $TOKEN" \
-H "ms-time: $MS_TIME" \
-H "ms-proof: $MS_PROOF" \
-H "Content-Type: application/json" \
-d '{"input":{"id":"msg_91b7e4c2a6f03d58b1c4e7a9"}}'
curl can’t sign a request. $TOKEN is your credential’s token, and $MS_TIME and $MS_PROOF sign this exact body: Calling the API without an SDK shows how.
mailset messages markUnread msg_91b7e4c2a6f03d58b1c4e7a9
{
"ok": true,
"data": {
"threadId": "out_3f9a1c0e7b2d"
}
}
messages.original
Get a message as it arrived, as an .eml file.
POST/v1/messages.original
Parameters
The message’s id, from
threads get.
Returns
data is an object with:
A file name for it, ending in
.eml.The raw message, base64.
import { Mailset } from 'mailset';
// Reads MAILSET_TOKEN from the environment.
const mailset = new Mailset();
const answer = await mailset.messages.original({
id: "msg_91b7e4c2a6f03d58b1c4e7a9",
});
console.log(answer);
from mailset import Mailset
# Reads MAILSET_TOKEN from the environment.
mailset = Mailset()
answer = mailset.messages.original(
{"id": "msg_91b7e4c2a6f03d58b1c4e7a9"}
)
print(answer)
package main
import (
"context"
"fmt"
"log"
mailset "mailset.app/go"
)
func main() {
// Reads MAILSET_TOKEN from the environment.
client, err := mailset.NewClient()
if err != nil {
log.Fatal(err)
}
ctx := context.Background()
params := &mailset.MessagesOriginalParams{
ID: "msg_91b7e4c2a6f03d58b1c4e7a9",
}
answer, err := client.Messages.Original(ctx, params)
if err != nil {
log.Fatal(err)
}
fmt.Println(answer)
}
require 'mailset'
# Reads MAILSET_TOKEN from the environment.
mailset = Mailset::Client.new
answer = mailset.messages.original(
id: 'msg_91b7e4c2a6f03d58b1c4e7a9'
)
p answer
<?php
require 'vendor/autoload.php';
// Reads MAILSET_TOKEN from the environment.
$mailset = new Mailset\Client();
$answer = $mailset->messages->original([
'id' => 'msg_91b7e4c2a6f03d58b1c4e7a9',
]);
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
import app.mailset.Mailset;
import app.mailset.model.MessagesOriginalParams;
import app.mailset.model.MessagesOriginalResult;
// Reads MAILSET_TOKEN from the environment.
Mailset mailset = Mailset.fromEnv();
var params = MessagesOriginalParams.builder()
.id("msg_91b7e4c2a6f03d58b1c4e7a9")
.build();
MessagesOriginalResult answer =
mailset.messages().original(params);
System.out.println(answer);
use mailset::types::MessagesOriginalParams;
// Reads MAILSET_TOKEN from the environment.
let mailset = mailset::Client::from_env()?;
let answer = mailset
.messages()
.original(MessagesOriginalParams {
id: "msg_91b7e4c2a6f03d58b1c4e7a9".into(),
})
.await?;
println!("{answer:?}");
curl https://mailset.app/v1/messages.original \
-H "Authorization: Bearer $TOKEN" \
-H "ms-time: $MS_TIME" \
-H "ms-proof: $MS_PROOF" \
-H "Content-Type: application/json" \
-d '{"input":{"id":"msg_91b7e4c2a6f03d58b1c4e7a9"}}'
curl can’t sign a request. $TOKEN is your credential’s token, and $MS_TIME and $MS_PROOF sign this exact body: Calling the API without an SDK shows how.
mailset messages original msg_91b7e4c2a6f03d58b1c4e7a9
{
"ok": true,
"data": {
"name": "Acme API",
"data": "<base64>"
}
}
messages.star
Star one message, or take its star off.
POST/v1/messages.star
Parameters
The message’s id, from
threads get.True to star it, false to take the star off.
Default
true.
Returns
data is an object with:
The conversation it’s in.
Whether the conversation is still starred.
import { Mailset } from 'mailset';
// Reads MAILSET_TOKEN from the environment.
const mailset = new Mailset();
const answer = await mailset.messages.star({
id: "msg_91b7e4c2a6f03d58b1c4e7a9",
});
console.log(answer);
from mailset import Mailset
# Reads MAILSET_TOKEN from the environment.
mailset = Mailset()
answer = mailset.messages.star(
{"id": "msg_91b7e4c2a6f03d58b1c4e7a9"}
)
print(answer)
package main
import (
"context"
"fmt"
"log"
mailset "mailset.app/go"
)
func main() {
// Reads MAILSET_TOKEN from the environment.
client, err := mailset.NewClient()
if err != nil {
log.Fatal(err)
}
ctx := context.Background()
params := &mailset.MessagesStarParams{
ID: "msg_91b7e4c2a6f03d58b1c4e7a9",
}
answer, err := client.Messages.Star(ctx, params)
if err != nil {
log.Fatal(err)
}
fmt.Println(answer)
}
require 'mailset'
# Reads MAILSET_TOKEN from the environment.
mailset = Mailset::Client.new
answer = mailset.messages.star(
id: 'msg_91b7e4c2a6f03d58b1c4e7a9'
)
p answer
<?php
require 'vendor/autoload.php';
// Reads MAILSET_TOKEN from the environment.
$mailset = new Mailset\Client();
$answer = $mailset->messages->star([
'id' => 'msg_91b7e4c2a6f03d58b1c4e7a9',
]);
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
import app.mailset.Mailset;
import app.mailset.model.MessagesStarParams;
import app.mailset.model.MessagesStarResult;
// Reads MAILSET_TOKEN from the environment.
Mailset mailset = Mailset.fromEnv();
var params = MessagesStarParams.builder()
.id("msg_91b7e4c2a6f03d58b1c4e7a9")
.build();
MessagesStarResult answer =
mailset.messages().star(params);
System.out.println(answer);
use mailset::types::MessagesStarParams;
// Reads MAILSET_TOKEN from the environment.
let mailset = mailset::Client::from_env()?;
let answer = mailset
.messages()
.star(MessagesStarParams {
id: "msg_91b7e4c2a6f03d58b1c4e7a9".into(),
..Default::default()
})
.await?;
println!("{answer:?}");
curl https://mailset.app/v1/messages.star \
-H "Authorization: Bearer $TOKEN" \
-H "ms-time: $MS_TIME" \
-H "ms-proof: $MS_PROOF" \
-H "Content-Type: application/json" \
-d '{"input":{"id":"msg_91b7e4c2a6f03d58b1c4e7a9"}}'
curl can’t sign a request. $TOKEN is your credential’s token, and $MS_TIME and $MS_PROOF sign this exact body: Calling the API without an SDK shows how.
mailset messages star msg_91b7e4c2a6f03d58b1c4e7a9
{
"ok": true,
"data": {
"threadId": "out_3f9a1c0e7b2d",
"starred": true
}
}
messages.delete
Delete one message for good, with its files.
POST/v1/messages.delete
Parameters
The message’s id, from
threads get.
Beside input
An approval’s id, once someone approved it with their passkey. Without one, the answer is
step_up_requiredand names what to approve.
Returns
data is an object with:
The conversation it was in.
True when it was the conversation’s last message, so the conversation went too.
import { Mailset } from 'mailset';
// Reads MAILSET_TOKEN from the environment.
const mailset = new Mailset();
const answer = await mailset.messages.delete({
id: "msg_91b7e4c2a6f03d58b1c4e7a9",
});
console.log(answer);
from mailset import Mailset
# Reads MAILSET_TOKEN from the environment.
mailset = Mailset()
answer = mailset.messages.delete(
{"id": "msg_91b7e4c2a6f03d58b1c4e7a9"}
)
print(answer)
package main
import (
"context"
"fmt"
"log"
mailset "mailset.app/go"
)
func main() {
// Reads MAILSET_TOKEN from the environment.
client, err := mailset.NewClient()
if err != nil {
log.Fatal(err)
}
ctx := context.Background()
params := &mailset.MessagesDeleteParams{
ID: "msg_91b7e4c2a6f03d58b1c4e7a9",
}
answer, err := client.Messages.Delete(ctx, params)
if err != nil {
log.Fatal(err)
}
fmt.Println(answer)
}
require 'mailset'
# Reads MAILSET_TOKEN from the environment.
mailset = Mailset::Client.new
answer = mailset.messages.delete(
id: 'msg_91b7e4c2a6f03d58b1c4e7a9'
)
p answer
<?php
require 'vendor/autoload.php';
// Reads MAILSET_TOKEN from the environment.
$mailset = new Mailset\Client();
$answer = $mailset->messages->delete([
'id' => 'msg_91b7e4c2a6f03d58b1c4e7a9',
]);
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
import app.mailset.Mailset;
import app.mailset.model.MessagesDeleteParams;
import app.mailset.model.MessagesDeleteResult;
// Reads MAILSET_TOKEN from the environment.
Mailset mailset = Mailset.fromEnv();
var params = MessagesDeleteParams.builder()
.id("msg_91b7e4c2a6f03d58b1c4e7a9")
.build();
MessagesDeleteResult answer =
mailset.messages().delete(params);
System.out.println(answer);
use mailset::types::MessagesDeleteParams;
// Reads MAILSET_TOKEN from the environment.
let mailset = mailset::Client::from_env()?;
let answer = mailset
.messages()
.delete(MessagesDeleteParams {
id: "msg_91b7e4c2a6f03d58b1c4e7a9".into(),
})
.await?;
println!("{answer:?}");
curl https://mailset.app/v1/messages.delete \
-H "Authorization: Bearer $TOKEN" \
-H "ms-time: $MS_TIME" \
-H "ms-proof: $MS_PROOF" \
-H "Content-Type: application/json" \
-d '{"input":{"id":"msg_91b7e4c2a6f03d58b1c4e7a9"}}'
curl can’t sign a request. $TOKEN is your credential’s token, and $MS_TIME and $MS_PROOF sign this exact body: Calling the API without an SDK shows how.
mailset messages delete msg_91b7e4c2a6f03d58b1c4e7a9
{
"ok": true,
"data": {
"threadId": "out_3f9a1c0e7b2d",
"threadRemoved": true
}
}
messages.report
Report one message as junk or phishing, and move it to Junk.
POST/v1/messages.report
Parameters
The message’s id, from
threads get.junkorphishing.One of
junkphishingDefault
junk.
Returns
data is an object with:
The conversation it’s in.
import { Mailset } from 'mailset';
// Reads MAILSET_TOKEN from the environment.
const mailset = new Mailset();
const answer = await mailset.messages.report({
kind: "phishing",
id: "msg_91b7e4c2a6f03d58b1c4e7a9",
});
console.log(answer);
from mailset import Mailset
# Reads MAILSET_TOKEN from the environment.
mailset = Mailset()
answer = mailset.messages.report(
{
"kind": "phishing",
"id": "msg_91b7e4c2a6f03d58b1c4e7a9",
}
)
print(answer)
package main
import (
"context"
"fmt"
"log"
mailset "mailset.app/go"
)
func main() {
// Reads MAILSET_TOKEN from the environment.
client, err := mailset.NewClient()
if err != nil {
log.Fatal(err)
}
ctx := context.Background()
params := &mailset.MessagesReportParams{
Kind: mailset.ReportKindPhishing,
ID: "msg_91b7e4c2a6f03d58b1c4e7a9",
}
answer, err := client.Messages.Report(ctx, params)
if err != nil {
log.Fatal(err)
}
fmt.Println(answer)
}
require 'mailset'
# Reads MAILSET_TOKEN from the environment.
mailset = Mailset::Client.new
answer = mailset.messages.report(
kind: 'phishing',
id: 'msg_91b7e4c2a6f03d58b1c4e7a9'
)
p answer
<?php
require 'vendor/autoload.php';
// Reads MAILSET_TOKEN from the environment.
$mailset = new Mailset\Client();
$answer = $mailset->messages->report([
'kind' => 'phishing',
'id' => 'msg_91b7e4c2a6f03d58b1c4e7a9',
]);
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
import app.mailset.Mailset;
import app.mailset.model.MessagesReportParams;
import app.mailset.model.MessagesReportResult;
import app.mailset.model.ReportKind;
// Reads MAILSET_TOKEN from the environment.
Mailset mailset = Mailset.fromEnv();
var params = MessagesReportParams.builder()
.kind(ReportKind.PHISHING)
.id("msg_91b7e4c2a6f03d58b1c4e7a9")
.build();
MessagesReportResult answer =
mailset.messages().report(params);
System.out.println(answer);
use mailset::types::{MessagesReportParams, ReportKind};
// Reads MAILSET_TOKEN from the environment.
let mailset = mailset::Client::from_env()?;
let answer = mailset
.messages()
.report(MessagesReportParams {
id: "msg_91b7e4c2a6f03d58b1c4e7a9".into(),
kind: Some(ReportKind::Phishing),
})
.await?;
println!("{answer:?}");
curl https://mailset.app/v1/messages.report \
-H "Authorization: Bearer $TOKEN" \
-H "ms-time: $MS_TIME" \
-H "ms-proof: $MS_PROOF" \
-H "Content-Type: application/json" \
-d '{"input":{"kind":"phishing","id":"msg_91b7e4c2a6f03d58b1c4e7a9"}}'
curl can’t sign a request. $TOKEN is your credential’s token, and $MS_TIME and $MS_PROOF sign this exact body: Calling the API without an SDK shows how.
mailset messages report msg_91b7e4c2a6f03d58b1c4e7a9 --kind phishing
{
"ok": true,
"data": {
"threadId": "out_3f9a1c0e7b2d"
}
}
messages.unsubscribe
Unsubscribe from whoever sent a message: asked for you, or their page to open.
POST/v1/messages.unsubscribe
Parameters
The message’s id, from
threads get.
Returns
data is an object with:
One of
sentfailedlinknone
import { Mailset } from 'mailset';
// Reads MAILSET_TOKEN from the environment.
const mailset = new Mailset();
const answer = await mailset.messages.unsubscribe({
id: "msg_91b7e4c2a6f03d58b1c4e7a9",
});
console.log(answer);
from mailset import Mailset
# Reads MAILSET_TOKEN from the environment.
mailset = Mailset()
answer = mailset.messages.unsubscribe(
{"id": "msg_91b7e4c2a6f03d58b1c4e7a9"}
)
print(answer)
package main
import (
"context"
"fmt"
"log"
mailset "mailset.app/go"
)
func main() {
// Reads MAILSET_TOKEN from the environment.
client, err := mailset.NewClient()
if err != nil {
log.Fatal(err)
}
ctx := context.Background()
params := &mailset.MessagesUnsubscribeParams{
ID: "msg_91b7e4c2a6f03d58b1c4e7a9",
}
answer, err := client.Messages.Unsubscribe(ctx, params)
if err != nil {
log.Fatal(err)
}
fmt.Println(answer)
}
require 'mailset'
# Reads MAILSET_TOKEN from the environment.
mailset = Mailset::Client.new
answer = mailset.messages.unsubscribe(
id: 'msg_91b7e4c2a6f03d58b1c4e7a9'
)
p answer
<?php
require 'vendor/autoload.php';
// Reads MAILSET_TOKEN from the environment.
$mailset = new Mailset\Client();
$answer = $mailset->messages->unsubscribe([
'id' => 'msg_91b7e4c2a6f03d58b1c4e7a9',
]);
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
import app.mailset.Mailset;
import app.mailset.model.MessagesUnsubscribeParams;
import app.mailset.model.UnsubscribeResult;
// Reads MAILSET_TOKEN from the environment.
Mailset mailset = Mailset.fromEnv();
var params = MessagesUnsubscribeParams.builder()
.id("msg_91b7e4c2a6f03d58b1c4e7a9")
.build();
UnsubscribeResult answer =
mailset.messages().unsubscribe(params);
System.out.println(answer);
use mailset::types::MessagesUnsubscribeParams;
// Reads MAILSET_TOKEN from the environment.
let mailset = mailset::Client::from_env()?;
let answer = mailset
.messages()
.unsubscribe(MessagesUnsubscribeParams {
id: "msg_91b7e4c2a6f03d58b1c4e7a9".into(),
})
.await?;
println!("{answer:?}");
curl https://mailset.app/v1/messages.unsubscribe \
-H "Authorization: Bearer $TOKEN" \
-H "ms-time: $MS_TIME" \
-H "ms-proof: $MS_PROOF" \
-H "Content-Type: application/json" \
-d '{"input":{"id":"msg_91b7e4c2a6f03d58b1c4e7a9"}}'
curl can’t sign a request. $TOKEN is your credential’s token, and $MS_TIME and $MS_PROOF sign this exact body: Calling the API without an SDK shows how.
mailset messages unsubscribe msg_91b7e4c2a6f03d58b1c4e7a9
{
"ok": true,
"data": {
"state": "sent",
"url": "https://hooks.example.com/mailset"
}
}
messages.submit
Send a whole RFC 5322 message as written.
POST/v1/messages.submit
Parameters
The whole RFC 5322 message, in base64, up to 20 MB.
A product’s own mail: no copy in Sent, nobody added to contacts, and only the delivery log remembers it.
Default
false.The kind of product mail.
transactional: a code or a receipt, which can’t carry List-Unsubscribe or Precedence: bulk.promotional: a newsletter or an offer, to one address in To; with no List-Unsubscribe of its own, Mailset adds a one-click one and puts the link at{{mailset_unsubscribe}}in the body, or on a last line.One of
transactionalpromotionalThe latest it may go out, in milliseconds since 1970. Held past it at submit, it is refused with
retryAt; still waiting when it comes, it is dropped unsent.
The body may be up to 28 MB.
Returns
data is the Receipt object.
import { Mailset } from 'mailset';
// Reads MAILSET_KEY from the environment.
const mailset = new Mailset();
const sent = await mailset.send({
from: 'Acme <moc.elpmaxe@olleh>',
to: 'gro.elpmaxe@ana',
subject: 'Your Acme code',
text: 'Your code is 123456.',
html: '<p>Your code is <b>123456</b>.</p>',
deliverBy: '10m',
});
console.log(sent.id, sent.status);
from mailset import Mailset
# Reads MAILSET_KEY from the environment.
mailset = Mailset()
sent = mailset.send(
{
"from": "Acme <moc.elpmaxe@olleh>",
"to": "gro.elpmaxe@ana",
"subject": "Your Acme code",
"text": "Your code is 123456.",
"html": "<p>Your code is <b>123456</b>.</p>",
"deliver_by": "10m",
}
)
print(sent["id"], sent["status"])
import (
"context"
"fmt"
"log"
"time"
mailset "mailset.app/go"
)
client, err := mailset.NewClient() // reads MAILSET_KEY
if err != nil {
log.Fatal(err)
}
ctx := context.Background()
sent, err := client.Send(ctx, mailset.Message{
From: "Acme <moc.elpmaxe@olleh>",
To: []string{"gro.elpmaxe@ana"},
require 'mailset'
mailset = Mailset::Client.new
sent = mailset.send_email(
from: 'Acme <moc.elpmaxe@olleh>',
to: 'gro.elpmaxe@ana',
subject: 'Your Acme code',
text: 'Your code is 123456.',
html: '<p>Your code is <b>123456</b>.</p>',
deliver_by: '10m'
)
puts sent.id, sent.status
<?php
require 'vendor/autoload.php';
// Reads MAILSET_KEY from the environment.
$mailset = new Mailset\Client();
$sent = $mailset->send([
'from' => 'Acme <moc.elpmaxe@olleh>',
'to' => 'gro.elpmaxe@ana',
'subject' => 'Your Acme code',
'text' => 'Your code is 123456.',
'html' => '<p>Your code is <b>123456</b>.</p>',
'deliverBy' => '10m',
]);
echo $sent->id, ' ', $sent->status, PHP_EOL;
import app.mailset.Mailset;
import app.mailset.Message;
import app.mailset.Sent;
// Reads MAILSET_KEY from the environment.
Mailset mailset = Mailset.fromEnv();
Sent sent = mailset.send(Message.builder()
.from("Acme <moc.elpmaxe@olleh>")
.to("gro.elpmaxe@ana")
.subject("Your Acme code")
.text("Your code is 123456.")
.html("<p>Your code is <b>123456</b>.</p>")
.deliverBy("10m")
.build());
System.out.println(sent.id() + " " + sent.status());
use mailset::{Client, Message};
// Reads MAILSET_KEY from the environment.
let mailset = Client::from_env()?;
let message = Message::builder()
.from("Acme <moc.elpmaxe@olleh>")
.to("gro.elpmaxe@ana")
.subject("Your Acme code")
.text("Your code is 123456.")
.html("<p>Your code is <b>123456</b>.</p>")
.deliver_by("10m");
let sent = mailset.send(message).await?;
println!("{} {:?}", sent.id, sent.status);
curl https://mailset.app/v1/messages.submit \
-H "Authorization: Bearer $TOKEN" \
-H "ms-time: $MS_TIME" \
-H "ms-proof: $MS_PROOF" \
-H "Content-Type: application/json" \
-d '{"input":{"transactional":true,"name":"receipt.eml","data":"<the message as base64>"}}'
curl can’t sign a request. $TOKEN is your credential’s token, and $MS_TIME and $MS_PROOF sign this exact body: Calling the API without an SDK shows how. <the message as base64> is a whole email, headers and body: Send your own MIME.
mailset messages submit --file receipt.eml --transactional
{
"ok": true,
"data": {
"id": "out_3f9a1c0e7b2d",
"sendAt": 1796048940000,
"state": "sent"
}
}
messages.submitMany
Send up to 100 whole messages, each with its own answer.
POST/v1/messages.submitMany
Parameters
The messages, 1 to 100, each as
messages submittakes one. 48 MB together, before base64.1 to 100 items.
Show child attributesHide child attributes
The whole RFC 5322 message, in base64, up to 20 MB.
A product’s own mail: no copy in Sent, nobody added to contacts, and only the delivery log remembers it.
Default
false.The kind of product mail.
transactional: a code or a receipt, which can’t carry List-Unsubscribe or Precedence: bulk.promotional: a newsletter or an offer, to one address in To; with no List-Unsubscribe of its own, Mailset adds a one-click one and puts the link at{{mailset_unsubscribe}}in the body, or on a last line.One of
transactionalpromotionalThe latest it may go out, in milliseconds since 1970. Held past it at submit, it is refused with
retryAt; still waiting when it comes, it is dropped unsent.
The body may be up to 67 MB.
Returns
data is an object with:
One answer per message, in the order they came:
ok: truewith its receipt, orok: falsewith the refusal.Show child attributesHide child attributes
Mailset’s id for this send.
The id its message will have in the conversation once it goes.
When it goes out, in milliseconds since 1970: the time asked, or later when a limit holds it.
Why it waits past the time asked: a sending limit that clears by waiting.
True when what holds it is one of the plan’s sending limits, which Mailset support can raise.
sent: it went, or every recipient was skipped and nothing is left to do.queued: Mailset holds it and sends it atsendAt.One of
sentqueuedRecipients Mailset left out. They never get it, the others do, and there is nothing to retry. Absent when nobody was skipped.
Mailset took this message.
Why, as any refused call says it: a stable
codeand amessagefor people.Show child attributesHide child attributes
What kind of refusal it is. The HTTP status follows from it.
One of
invalid_inputunauthorizedstep_up_requiredforbiddennot_foundconflictexpiredlimit_reachedunavailableinternalThe refusal in words, fit to show a person.
On
invalid_input: each field that was wrong.On
step_up_required: the action a passkey has to approve.Show child attributesHide child attributes
What the action is about: a
domain, amailbox, amemberand so on.One of
devicememberpasskeydomainmailboxtokenapprovalruleforwardmessagegrouppolicyexportaccountrecoverypaperkeydnsgoogleaiThe action itself, as text a passkey check is made for.
The org it’s in. Null for an action on your own account.
When mail was refused: why, as a short code.
One of
domain_pendingdomain_blockedprovider_refusedrecipientmail_domainseat_chargeOn
limit_reachedfor mail with a deadline: the soonest it could go, in ms since the epoch. Send it again then, or with a later deadline.When a sending limit refused it: the page that lists every plan’s limits, as a URL.
When Mailset support can raise the limit that refused it: where to ask, as a URL.
On
unauthorized: this device was signed out for good, not just out of time.On a refused address: the one it likely meant, for the person to pick or ignore.
import { Mailset } from 'mailset';
// Reads MAILSET_KEY from the environment.
const mailset = new Mailset();
const results = await mailset.send([
{
from: 'Acme <moc.elpmaxe@olleh>',
to: 'gro.elpmaxe@ana',
subject: 'Your invoice',
text: 'Invoice 8842 is ready.',
},
{
from: 'Acme <moc.elpmaxe@olleh>',
to: 'gro.elpmaxe@neb',
subject: 'Your invoice',
text: 'Invoice 8843 is ready.',
},
]);
for (const result of results) {
if (result.ok) console.log(result.id, result.status);
else console.error(result.messageId, result.error.code);
}
from mailset import Mailset
# Reads MAILSET_KEY from the environment.
mailset = Mailset()
results = mailset.send(
[
{
"from": "Acme <moc.elpmaxe@olleh>",
"to": "gro.elpmaxe@ana",
"subject": "Your invoice",
"text": "Invoice 8842 is ready.",
},
{
"from": "Acme <moc.elpmaxe@olleh>",
"to": "gro.elpmaxe@neb",
"subject": "Your invoice",
"text": "Invoice 8843 is ready.",
},
]
)
for result in results:
if result["ok"]:
print(result["id"], result["status"])
else:
print(result["message_id"], result["error"].code)
import (
"context"
"fmt"
"log"
mailset "mailset.app/go"
)
client, err := mailset.NewClient() // reads MAILSET_KEY
if err != nil {
log.Fatal(err)
}
ctx := context.Background()
results, err := client.SendMany(ctx, []mailset.Message{
{
From: "Acme <moc.elpmaxe@olleh>",
To: []string{"gro.elpmaxe@ana"},
require 'mailset'
mailset = Mailset::Client.new
results = mailset.send_emails([
{
from: 'Acme <moc.elpmaxe@olleh>',
to: 'gro.elpmaxe@ana',
subject: 'Your invoice',
text: 'Invoice 8842 is ready.'
},
{
from: 'Acme <moc.elpmaxe@olleh>',
to: 'gro.elpmaxe@neb',
subject: 'Your invoice',
text: 'Invoice 8843 is ready.'
}
])
results.each do |result|
if result.ok?
puts "#{result.id} #{result.status}"
else
warn "#{result.message_id} #{result.error.code}"
end
end
<?php
require 'vendor/autoload.php';
use Mailset\Sent;
// Reads MAILSET_KEY from the environment.
$mailset = new Mailset\Client();
$results = $mailset->sendMany([
[
'from' => 'Acme <moc.elpmaxe@olleh>',
'to' => 'gro.elpmaxe@ana',
'subject' => 'Your invoice',
'text' => 'Invoice 8842 is ready.',
],
[
'from' => 'Acme <moc.elpmaxe@olleh>',
import app.mailset.Mailset;
import app.mailset.Message;
import app.mailset.NotSent;
import app.mailset.SendResult;
import app.mailset.Sent;
import java.util.List;
// Reads MAILSET_KEY from the environment.
Mailset mailset = Mailset.fromEnv();
List<SendResult> results = mailset.send(List.of(
Message.builder()
.from("Acme <moc.elpmaxe@olleh>")
.to("gro.elpmaxe@ana")
.subject("Your invoice")
.text("Invoice 8842 is ready.")
.build(),
Message.builder()
use mailset::{Client, Message};
// Reads MAILSET_KEY from the environment.
let mailset = Client::from_env()?;
let invoice = |to: &str, number: u32| {
Message::builder()
.from("Acme <moc.elpmaxe@olleh>")
.to(to)
.subject("Your invoice")
.text(format!("Invoice {number} is ready."))
};
let messages = [
invoice("gro.elpmaxe@ana", 8842),
invoice("gro.elpmaxe@neb", 8843),
];
let results = mailset.send_many(messages).await?;
for result in results {
match result {
Ok(sent) => println!("{}", sent.id),
Err(not) => eprintln!("{}", not.error),
}
}
curl https://mailset.app/v1/messages.submitMany \
-H "Authorization: Bearer $TOKEN" \
-H "ms-time: $MS_TIME" \
-H "ms-proof: $MS_PROOF" \
-H "Content-Type: application/json" \
-d '{"input":{"messages":[{"data":"<the message as base64>","transactional":true}]}}'
curl can’t sign a request. $TOKEN is your credential’s token, and $MS_TIME and $MS_PROOF sign this exact body: Calling the API without an SDK shows how. <the message as base64> is a whole email, headers and body: Send your own MIME.
mailset messages submitMany --messages @messages.json
[
{
"data": "<the message as base64>",
"transactional": true
}
]
<the message as base64> is a whole email, headers and body: Send your own MIME.
{
"ok": true,
"data": {
"results": [
{
"ok": true,
"id": "out_3f9a1c0e7b2d",
"sendAt": 1796048940000,
"state": "sent"
},
{
"ok": true,
"id": "out_8d2k4m1p9q7x",
"sendAt": 1796048940000,
"state": "sent",
"skipped": [
{
"address": "moc.dielppa.yaleretavirp@m4dq9p2k7x",
"reason": "private_relay"
}
]
}
]
}
}
messages.cancel
Take back a message that hasn’t gone yet.
POST/v1/messages.cancel
Parameters
The waiting message’s id, from
messages sendormessages scheduled.
Returns
data is an object with:
True when it was still waiting and won’t go.
import { Mailset } from 'mailset';
// Reads MAILSET_TOKEN from the environment.
const mailset = new Mailset();
const answer = await mailset.messages.cancel({
id: "out_2e8b6d1f4a9c3075d6b1e8a4",
});
console.log(answer);
from mailset import Mailset
# Reads MAILSET_TOKEN from the environment.
mailset = Mailset()
answer = mailset.messages.cancel(
{"id": "out_2e8b6d1f4a9c3075d6b1e8a4"}
)
print(answer)
package main
import (
"context"
"fmt"
"log"
mailset "mailset.app/go"
)
func main() {
// Reads MAILSET_TOKEN from the environment.
client, err := mailset.NewClient()
if err != nil {
log.Fatal(err)
}
ctx := context.Background()
params := &mailset.MessagesCancelParams{
ID: "out_2e8b6d1f4a9c3075d6b1e8a4",
}
answer, err := client.Messages.Cancel(ctx, params)
if err != nil {
log.Fatal(err)
}
fmt.Println(answer)
}
require 'mailset'
# Reads MAILSET_TOKEN from the environment.
mailset = Mailset::Client.new
answer = mailset.messages.cancel(
id: 'out_2e8b6d1f4a9c3075d6b1e8a4'
)
p answer
<?php
require 'vendor/autoload.php';
// Reads MAILSET_TOKEN from the environment.
$mailset = new Mailset\Client();
$answer = $mailset->messages->cancel([
'id' => 'out_2e8b6d1f4a9c3075d6b1e8a4',
]);
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
import app.mailset.Mailset;
import app.mailset.model.MessagesCancelParams;
import app.mailset.model.MessagesCancelResult;
// Reads MAILSET_TOKEN from the environment.
Mailset mailset = Mailset.fromEnv();
var params = MessagesCancelParams.builder()
.id("out_2e8b6d1f4a9c3075d6b1e8a4")
.build();
MessagesCancelResult answer =
mailset.messages().cancel(params);
System.out.println(answer);
use mailset::types::MessagesCancelParams;
// Reads MAILSET_TOKEN from the environment.
let mailset = mailset::Client::from_env()?;
let answer = mailset
.messages()
.cancel(MessagesCancelParams {
id: "out_2e8b6d1f4a9c3075d6b1e8a4".into(),
})
.await?;
println!("{answer:?}");
curl https://mailset.app/v1/messages.cancel \
-H "Authorization: Bearer $TOKEN" \
-H "ms-time: $MS_TIME" \
-H "ms-proof: $MS_PROOF" \
-H "Content-Type: application/json" \
-d '{"input":{"id":"out_2e8b6d1f4a9c3075d6b1e8a4"}}'
curl can’t sign a request. $TOKEN is your credential’s token, and $MS_TIME and $MS_PROOF sign this exact body: Calling the API without an SDK shows how.
mailset messages cancel out_2e8b6d1f4a9c3075d6b1e8a4
{
"ok": true,
"data": {
"cancelled": true
}
}
messages.sendNow
Send a message held for Undo now, without waiting out its time.
POST/v1/messages.sendNow
Parameters
The waiting message’s id, from
messages send.
Returns
data is the Receipt object.
import { Mailset } from 'mailset';
// Reads MAILSET_TOKEN from the environment.
const mailset = new Mailset();
const answer = await mailset.messages.sendNow({
id: "out_2e8b6d1f4a9c3075d6b1e8a4",
});
console.log(answer);
from mailset import Mailset
# Reads MAILSET_TOKEN from the environment.
mailset = Mailset()
answer = mailset.messages.send_now(
{"id": "out_2e8b6d1f4a9c3075d6b1e8a4"}
)
print(answer)
package main
import (
"context"
"fmt"
"log"
mailset "mailset.app/go"
)
func main() {
// Reads MAILSET_TOKEN from the environment.
client, err := mailset.NewClient()
if err != nil {
log.Fatal(err)
}
ctx := context.Background()
params := &mailset.MessagesSendNowParams{
ID: "out_2e8b6d1f4a9c3075d6b1e8a4",
}
answer, err := client.Messages.SendNow(ctx, params)
if err != nil {
log.Fatal(err)
}
fmt.Println(answer)
}
require 'mailset'
# Reads MAILSET_TOKEN from the environment.
mailset = Mailset::Client.new
answer = mailset.messages.send_now(
id: 'out_2e8b6d1f4a9c3075d6b1e8a4'
)
p answer
<?php
require 'vendor/autoload.php';
// Reads MAILSET_TOKEN from the environment.
$mailset = new Mailset\Client();
$answer = $mailset->messages->sendNow([
'id' => 'out_2e8b6d1f4a9c3075d6b1e8a4',
]);
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
import app.mailset.Mailset;
import app.mailset.model.MessagesSendNowParams;
import app.mailset.model.Receipt;
// Reads MAILSET_TOKEN from the environment.
Mailset mailset = Mailset.fromEnv();
var params = MessagesSendNowParams.builder()
.id("out_2e8b6d1f4a9c3075d6b1e8a4")
.build();
Receipt answer = mailset.messages().sendNow(params);
System.out.println(answer);
use mailset::types::MessagesSendNowParams;
// Reads MAILSET_TOKEN from the environment.
let mailset = mailset::Client::from_env()?;
let answer = mailset
.messages()
.send_now(MessagesSendNowParams {
id: "out_2e8b6d1f4a9c3075d6b1e8a4".into(),
})
.await?;
println!("{answer:?}");
curl https://mailset.app/v1/messages.sendNow \
-H "Authorization: Bearer $TOKEN" \
-H "ms-time: $MS_TIME" \
-H "ms-proof: $MS_PROOF" \
-H "Content-Type: application/json" \
-d '{"input":{"id":"out_2e8b6d1f4a9c3075d6b1e8a4"}}'
curl can’t sign a request. $TOKEN is your credential’s token, and $MS_TIME and $MS_PROOF sign this exact body: Calling the API without an SDK shows how.
mailset messages sendNow out_2e8b6d1f4a9c3075d6b1e8a4
{
"ok": true,
"data": {
"id": "out_3f9a1c0e7b2d",
"messageId": "moc.elpmaxe@85a4d2b7e0c1a9f3",
"sendAt": 1796048940000,
"state": "sent"
}
}
messages.scheduled
List mail waiting for its time.
POST/v1/messages.scheduled
Parameters
It takes no input: send an empty object.
Returns
data is a list of objects, each with:
The id to cancel it or send it now by.
The mailbox it goes out from.
Its From address.
Who it goes to.
Its subject.
The start of its text.
When it goes out, in milliseconds since 1970.
Cancelling puts it back in Drafts.
Why it hasn’t gone yet when its time has come, such as a sending limit. It goes out at
sendAt.True when what holds it is one of the plan’s sending limits, which Mailset support can raise.
import { Mailset } from 'mailset';
// Reads MAILSET_TOKEN from the environment.
const mailset = new Mailset();
const answer = await mailset.messages.scheduled();
console.log(answer);
from mailset import Mailset
# Reads MAILSET_TOKEN from the environment.
mailset = Mailset()
answer = mailset.messages.scheduled()
print(answer)
package main
import (
"context"
"fmt"
"log"
mailset "mailset.app/go"
)
func main() {
// Reads MAILSET_TOKEN from the environment.
client, err := mailset.NewClient()
if err != nil {
log.Fatal(err)
}
ctx := context.Background()
answer, err := client.Messages.Scheduled(ctx)
if err != nil {
log.Fatal(err)
}
fmt.Println(answer)
}
require 'mailset'
# Reads MAILSET_TOKEN from the environment.
mailset = Mailset::Client.new
answer = mailset.messages.scheduled
p answer
<?php
require 'vendor/autoload.php';
// Reads MAILSET_TOKEN from the environment.
$mailset = new Mailset\Client();
$answer = $mailset->messages->scheduled();
echo json_encode($answer, JSON_PRETTY_PRINT), PHP_EOL;
import app.mailset.Mailset;
import app.mailset.model.Scheduled;
import java.util.List;
// Reads MAILSET_TOKEN from the environment.
Mailset mailset = Mailset.fromEnv();
List<Scheduled> answer = mailset.messages().scheduled();
System.out.println(answer);
// Reads MAILSET_TOKEN from the environment.
let mailset = mailset::Client::from_env()?;
let answer = mailset.messages().scheduled().await?;
println!("{answer:?}");
curl https://mailset.app/v1/messages.scheduled \
-H "Authorization: Bearer $TOKEN" \
-H "ms-time: $MS_TIME" \
-H "ms-proof: $MS_PROOF" \
-H "Content-Type: application/json" \
-d '{"input":{}}'
curl can’t sign a request. $TOKEN is your credential’s token, and $MS_TIME and $MS_PROOF sign this exact body: Calling the API without an SDK shows how.
mailset messages scheduled
{
"ok": true,
"data": [
{
"id": "out_3f9a1c0e7b2d",
"mailbox": "text",
"from": "moc.elpmaxe@olleh",
"to": [
"moc.elpmaxe@ana"
],
"subject": "Your Acme receipt",
"snippet": "text",
"sendAt": 1796048940000,
"hasDraft": true,
"held": "The day’s sending limit is reached.",
"raisable": true
}
]
}