NevarMail

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

  1. An inbound email arrives via your provider's webhook (e.g., SendGrid Inbound Parse)
  2. NevarMail evaluates the email against all enabled routing rules, sorted by priority
  3. For each matching rule, the configured actions are executed
  4. 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

FieldTypeRequiredDescription
namestringYesRule name
prioritynumberNoEvaluation order (lower = evaluated first)
isEnabledbooleanNoWhether the rule is active (default: true)
conditionsarrayYesMatch conditions (all must match)
actionsarrayYesActions to execute on match
metadataobjectNoArbitrary metadata

Condition operators

OperatorDescriptionExample
containsField contains the value{ "field": "subject", "operator": "contains", "value": "urgent" }
equalsField exactly matches the value{ "field": "from", "operator": "equals", "value": "bot@service.com" }
greater_thanField is greater than the value{ "field": "size", "operator": "greater_than", "value": "1000000" }
less_thanField 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 address
  • to -- Recipient email address
  • subject -- Email subject line
  • body -- Email body content
  • size -- Email size in bytes
  • Any custom header

Action types

TypeFieldsDescription
webhookurlSend the email data to a webhook URL
storebucketStore the email in a named bucket
forwardemailForward the email to another address

List rules

GET /api/inbound/rules

Update a rule

PUT /api/inbound/rules/:id
{
  "priority": 5,
  "isEnabled": false
}

Delete a rule

DELETE /api/inbound/rules/:id

Test 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.

On this page