Forward inbound email
Forward mail that arrives at your domains to outside addresses, and control which rule wins when several match.
A forwarding rule sends mail that arrives at one of your addresses on to addresses outside Samva.
Each rule has a source pattern, one or more forwardTo addresses, and a priority. When a message
matches more than one rule, exactly one rule forwards it.
Catch-all receiving can be enabled before you create a forwarding rule, webhook endpoint, or mailbox. Without a catch-all webhook endpoint, mail that matches neither a forwarding rule nor an active mailbox is dropped by default. You can instead deliver unknown addresses to one mailbox on the domain. Unknown addresses never generate bounces or delivery-status notifications.
To stop catch-all webhook delivery while keeping receiving enabled, choose Remove webhook in
the domain's receiving settings, or send endpointId: null to
update catch-all configuration. Forwarding rules
and mailbox delivery continue; unknown addresses follow the domain's saved unknown-address setting.
Create a rule
import { createClient } from "samva";
const samva = createClient({ apiKey: process.env.SAMVA_API_KEY! });
await samva.email.createForwardingRule({
name: "Support",
domainId: "dom_abc123",
sourcePattern: "support@example.com",
forwardTo: ["team@example.org"],
});sourcePattern is matched against the recipient address, ignoring case. An exact address matches
only that address, * inside a pattern matches any run of characters (sales-*@example.com), and
* alone, an empty pattern, or no pattern matches every address. Omit domainId to apply a rule to
every domain in your organization.
Which rule wins
Samva tries rules in this order and forwards with the first rule that matches:
- Priority, highest first. Priority is a whole number, 0 or higher, and defaults to 0.
- Specificity, at equal priority. An exact address comes before a pattern with a wildcard, and a
wildcard pattern with more literal characters comes before one with fewer
(
support-*@example.combefores*@example.com).*, an empty pattern, and no pattern come last. - Age, at equal specificity. The rule created first wins.
- Rule ID, so the order is always the same.
With every rule at the default priority, support@example.com therefore beats *@example.com
whichever you created first. Raise a rule's priority to override specificity, for example to send
everything to one address during an incident.
List forwarding rules returns rules in this order, and
the dashboard shows each rule's position and priority on the domain's Forwarding section. Filtering
by domainId returns that domain's rules together with the rules that apply to every domain
(domainId is null), which is the order mail for that domain is tried in.
Attachments and original email
Forwarded email includes the original attachments and inline images. Filenames, content types, file
contents, and inline image links are preserved. Samva adds forwarding context to the email body;
the stored original inbound MIME remains unchanged and is available through the message's
downloadUrls.rawMime.
Forwarding follows the email attachment limits.
Files that exceed a per-file limit, the attachment count, or the combined size limit, and files with
unsupported filenames, content types, or Content-ID values, are omitted;
the remaining files are forwarded. Both the text and HTML bodies name the omitted files. The
forwarding log’s errorMessage identifies the omissions, and Samva records an operational warning
event. Check the original inbound email to retrieve omitted files.
Reference
Related documentation
Import a reader list
Preview exports from beehiiv, Substack, Kit, or Mailchimp, preserve reader restrictions, and track an import through completion.
Verify your sending domain
Verify a domain in Samva so you can send email from your own address. Add the domain, publish the DNS records Samva provides, and confirm verification.