Send from a domain whose mail stays elsewhere

Send from a domain whose mail stays elsewhere

Send as your domain’s addresses while your team’s mail stays at Google or Microsoft.

Your team reads its mail in Google Workspace, Microsoft 365 or anywhere else, and your product's email should come from the same domain. Mailset sends for the domain and leaves its MX alone. Your key sends as the addresses your product uses, with no mailbox to make.

  1. Add the domain as sending-only: mailset domains add example.com --sending, or in Settings › Domains › Add domain with "Your team's mail stays where it is" ticked. Mailset asks only for the records sending needs: DKIM, the bounce host and DMARC. Your MX and SPF stay as they are. A subdomain such as mail.example.com works the same way, if you'd rather keep your product's sending reputation apart from your team's own mail.
  2. Put the records in DNS: mailset domains apply example.com --sending writes them where Mailset can reach your DNS host, mailset domains connect example.com --sending gives a one-click link where your DNS host supports it, and mailset guide dns-by-hand covers the rest.
  3. Run mailset domains check example.com until it says ready.
  4. Make a key for the addresses your product sends as: mailset keys create --send --domain example.com --from moc.elpmaxe@olleh --from moc.elpmaxe@ylperon --name "Example API". A key that may send as any address could send as your CEO, so name the ones your product uses. An owner or admin approves it with a passkey. Keep the MAILSET_KEY it prints in your secret store.
  5. Send as one of those addresses. The SDK reads the key from MAILSET_KEY:
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);

To have replies land where your team reads mail, add replyTo: 'moc.elpmaxe@troppus' to the send.

The key sends as those addresses and no other. A send as anything else is refused with the list it may use. Change the list with mailset keys update <id> --from …, which asks for your passkey again. The key covers example.com and nothing under it. Send newsletters from news.example.com with a key of its own, so a paused newsletter key never stops sign-in codes. Where nobody has a mailbox, as on a notifications subdomain, --any-address in place of --from lets the key send as any address there.

Nothing is kept in a mailbox, because there isn't one: the delivery log is the record (mailset delivery search, or mailset.delivery.search() with the key), and your webhook hears every outcome. keepCopy is refused for the same reason.

If the domain later moves its mail to Mailset (mailset domains apply example.com without --sending), its domain keys stop, because on a domain that holds your team's mailboxes a key for the domain could pass for any of them. Every owner gets a notice, and you make a key for one mailbox instead.