Inbound Routing
Configure rule-based routing for incoming emails with flexible conditions and actions.
NevarMail's inbound routing system lets you define rules that automatically process incoming emails based on conditions you specify. Rules are evaluated in priority order, and matching emails trigger the configured actions.
How it works
- An inbound email arrives via your provider's webhook (e.g., SendGrid Inbound Parse)
- NevarMail evaluates the email against all enabled routing rules, sorted by priority
- For each matching rule, the configured actions are executed
- Multiple rules can match the same email
Create a routing rule
POST /api/inbound/rules
{
"name": "Forward support emails",
"priority": 0,
"isEnabled": true,
"conditions": [
{ "field": "to", "operator": "contains", "value": "support@" }
],
"actions": [
{ "type": "webhook", "url": "https://your-app.com/webhooks/support" }
]
}Rule fields
| Field | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Rule name |
priority | number | No | Evaluation order (lower = evaluated first) |
isEnabled | boolean | No | Whether the rule is active (default: true) |
conditions | array | Yes | Match conditions (all must match) |
actions | array | Yes | Actions to execute on match |
metadata | object | No | Arbitrary metadata |
Condition operators
| Operator | Description | Example |
|---|---|---|
contains | Field contains the value | { "field": "subject", "operator": "contains", "value": "urgent" } |
equals | Field exactly matches the value | { "field": "from", "operator": "equals", "value": "bot@service.com" } |
greater_than | Field is greater than the value | { "field": "size", "operator": "greater_than", "value": "1000000" } |
less_than | Field is less than the value | { "field": "size", "operator": "less_than", "value": "500" } |
Condition fields
You can match against any field on the inbound email payload:
from-- Sender email addressto-- Recipient email addresssubject-- Email subject linebody-- Email body contentsize-- Email size in bytes- Any custom header
Action types
| Type | Fields | Description |
|---|---|---|
webhook | url | Send the email data to a webhook URL |
store | bucket | Store the email in a named bucket |
forward | email | Forward the email to another address |
List rules
GET /api/inbound/rulesUpdate a rule
PUT /api/inbound/rules/:id
{
"priority": 5,
"isEnabled": false
}Delete a rule
DELETE /api/inbound/rules/:idTest routing
Test how an email would be routed without actually processing it:
POST /api/inbound/test
{
"from": "customer@example.com",
"to": "support@yourdomain.com",
"subject": "Help with my order",
"body": "I need assistance with order #1234"
}{
"matchedRules": [
{
"ruleId": "...",
"ruleName": "Forward support emails",
"actions": [{ "type": "webhook", "url": "https://your-app.com/webhooks/support" }]
}
],
"totalRulesEvaluated": 5
}This is useful for verifying your rules work as expected before enabling them in production.