Mailset docs
Send email from your product with an SDK, the CLI or the HTTP API, and hear what became of each message.
Mailset sends your product's email from your own domain, whether your team's mail lives in Mailset or stays where it is. Sign-in codes, receipts, announcements: you call it from your server, it tells you what became of each message, and replies go wherever you point them.
Pick your language. The docs remember it and show every example in it.
- TypeScriptand JavaScript · Node.js 20+, Bun 1.4+, Deno 2.9+, Cloudflare Workers
- PythonPython 3.9+
- GoGo 1.22+
- RubyRuby 3.0+
- PHPPHP 8.1+
- JavaJava 17+
- RustRust 1.88+
- CLImacOS, Linux
- HTTP APIAny language
- Every public command
- Retries built in
- Timeouts per try
- Idempotency keys
- Webhook verification
- Credential check
Or start from your framework. Each guide runs from install to webhooks.
- Next.jsTypeScript · send and webhooks
- ExpressTypeScript · send and webhooks
- NestJSTypeScript · send and webhooks
- Cloudflare WorkersTypeScript · send and webhooks
- FastAPIPython · send and webhooks
- DjangoPython · send and webhooks
- FlaskPython · send and webhooks
- RailsRuby · send and webhooks
- LaravelPHP · send and webhooks
- SymfonyPHP · send and webhooks
- Spring BootJava · send and webhooks
On this page
Send your first email
- Make a key and approve it with your passkey. If your team's mail stays where it is, the key sends as the addresses you name on your domain:
mailset keys create --send --domain example.com --from moc.elpmaxe@olleh --name "Acme API", and Send from a domain whose mail stays elsewhere has the rest. If your team's mailboxes live in Mailset, make it for one mailbox instead:mailset keys create --send --mailbox moc.elpmaxe@olleh --name "Acme API". - Keep the
MAILSET_KEYit prints in your secret store. It shows once. - Install the SDK.
npm install mailset
pip install mailset
go get mailset.app/go
gem install mailset
composer require mailset-app/php
implementation("app.mailset:java:0.7.0")
cargo add mailset
- Send.
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);
From a terminal, mailset messages submit --file code.eml --transactional sends a message you have as a file.
Without an SDK, you build the message and sign the request yourself: Send your own MIME has the code in each language.
No domain on Mailset yet? mailset guide onboarding sets one up, and the same steps are at mailset.app/guide/onboarding.
What to read next
- Authentication: make a key, give it to the SDK, and keep it alive.
- API reference: every command as an HTTP request. It is also one file, openapi.json.
- CLI reference: every
mailsetcommand with its flags. - Webhooks: delivered, bounced, complained, unsubscribed and the rest, posted to your server.
- Recipes: a domain whose mail stays elsewhere, unsubscribes, bounces, deadlines for codes, batches, retries.
- Errors and limits: every error code, and what a sending limit does.
For agents
Every page here has a Markdown twin at its address plus .md, and llms.txt lists them all. An agent with a terminal can skip the docs: mailset --help lists every command, and mailset guide prints the setup recipes.