maddy icon indicating copy to clipboard operation
maddy copied to clipboard

Setup $(local_domains) from table instead of maddy.conf

Open fgma opened this issue 4 years ago • 3 comments

Use case

I'd like to load $(local_domains) from a table like sqlite. Right now I need to specify domains in maddy.conf but my accounts and aliases are all setup inside sqlite.

Your idea for a solution

  • [ ] I'm willing to help with the implementation

fgma avatar Mar 07 '21 20:03 fgma

0.5 will introduce table.chain that can be used to combine multiple table modules.

What you want would be possible by pulling together table.regexp and table.sql_query/sql_table.

For example, this "table" will define all possible addresses:

table.chain possible_addrs {
  step regexp ".+@(.+)" "$1"
  step sql_table {
    driver sqlite3
    dsn credentials.db
    table_name domains
  }
}

(Basically, first step extracts domain from the address and second looks that domain up in a DB table)

Then relevant destination directives could be replaced with destination_in:

E.g.

destination_in &possible_addrs {
  deliver_to &local_routing
}

foxcpp avatar Mar 07 '21 20:03 foxcpp

Would it also be possible to have a generic configuration for a catch-all which fetches an optional catch-all target address for addresses that don't exist from a table?

fgma avatar Mar 08 '21 11:03 fgma

Rewritting all addresses to an internal address like [email protected] and then looking it up in the table should be the way to go:

table.chain catch_all {
  step regexp ".*" "[email protected]"
  step sql_table {
    driver sqlite3
    dsn catchalldb
    table_name catchall
  }
}

foxcpp avatar May 24 '21 03:05 foxcpp