Commit Graph
5 Commits
Author SHA1 Message Date
Wez Furlong db5ebb88a7 message: expose recipient list to lua api
message:recipient() may now return an array style table
holding the recipient list, if there is more than a single
recipient on the message.

Since this can be somewhat ambiguous/frustrating to work with,
there is now also a message:recipient_list() that will always
return an array style table, even if it holds just a single
element.

The included helpers have been updated to use `message:recipient_list`.

message:set_recipient() will now optionally accept an array
style table holding the recipient list to be set.
2025-10-07 07:52:58 +01:00
Nathalie CaiandNathalie Cai 6bb9ac387c add mx_list_ip_map to smtp protocole for tls connection (#80)
add mx_list_ip_map to smtp protocole for tls connection

Co-authored-by: Nathalie Cai <ncai@chapsvision.com>
2023-08-30 08:29:18 -07:00
Wez Furlong a73912e7e1 rollup.lua: remove stray debug print 2023-08-12 07:24:29 -07:00
Wez Furlong 7aa80bc34a rollup.lua: add ip-based rollup
How it works:

* When the lowest preference MX host names match a pattern like
  `.mail.protection.outlook.com`, the message has its routing_domain
  set to a placeholder domain whose name ends with `.ip_rollup`.
* That results in a scheduled queue name like
  `foo.com!outlook.ip_rollup`, which makes it possible to know both the
  original domain and the fact that rollup is in use.
* `get_queue_config` can check to see if the routing_domain is set to
  something that ends with `.ip_rollup` to override the `mx_list`
  in the queue configuration with just the lowest preference IP
  addresses from the original domain.
* Now, instead of computing a site_name base around
  `foo-com.mail.protection.outlook.com`, which includes the individual
  original recipient domain, and would cause there to be a separate
  ready queue for each domain, the overridden mx_list causes
  the site_name to be eg: `mx_list:[104.47.24.36],[104.47.25.36]`.
  That same site_name will be used for every domain that shares those
  same IP addresses
* When `get_egress_path_config` is called to get shaping parameters,
  it is passed the routing domain `outlook.ip_rollup`. You can use that
  name with mx_rollup=false as the key in your shaping.toml, of if you
  are directly implementing `get_egress_path_config`, you can use that
  name to determine the appropriate configuration.

```lua
kumo.on('get_queue_config', function(domain, tenant, campaign, routing_domain)
  local params = {}
  rollup.apply_ip_rollup_to_queue_config(domain, routing_domain, params
  return kumo.make_queue_config(params)
end)

kumo.on('smtp_server_message_received', function(msg)
  rollup.reroute_using_ip_rollup(msg, {
    ['.mail.protection.outlook.com.'] = 'outlook.ip_rollup',
  })
end)
```

In your shaping.toml:

```toml
["outlook.ip_rollup"]
mx_rollup = false
 # shaping parameters here
```

Caveats:

* With this technique, we'll never try to use any of the lower
  priority/higher preference value MX records for any of the matching
  domains.
* The IP addresses to which the MX host names resolve can vary over time.
  We'll still queue the mail to the same scheduled queue (eg:
  `foo.com!outlook.ip_rollup`), but it's possible for there to be
  multiple ready queues with different names based on those changed
  IPs.  This is actually a feature: if the destination domain has
  an outage and are now publishing different IPs, we'll pick those up
  and use them.
* Since the ready queue names look like `mx_list:[104.47.24.36],[104.47.25.36]`
  it can be hard to intuit just from glancing at that name where those queues go.
2023-08-12 06:52:39 -07:00
Wez Furlong 67b71a8b83 policy-extras: add rollup.lua
This is a prototype of a means for dealing with rolling up microsoft's
domains so that shaping can be applied holistically over both eg:
hotmail.com and outlook.com.

Those domains don't work with our default automatic MX based rollup
because they don't return the same MX hostnames.

Checking this in to make it easier for others to test/evaluate.
In the future, we may find a way to integrate this with our main
shaping helpers.
2023-08-10 11:48:07 -07:00