Skip to content

host selection for services, database field #145

Description

@runout-at

i'd like to have a new feature which would make it easier to switch services between servers and make migration easier.
The server/service could retrieve a 'host' field from the database to decide if the domain belongs to it.
I suggest to have different 'host' fields for different services: smtp, imap, pop

Dovecot has such a feature for its proxy: http://wiki2.dovecot.org/PasswordDatabase/ExtraFields/Proxy

Database fields:

ALTER TABLE `maildb_vexim2`.`domainalias` 
ADD COLUMN `host_smtp` VARCHAR(64) NULL DEFAULT 'mail' COMMENT '' AFTER `alias`,
ADD COLUMN `host_imap` VARCHAR(64) NULL DEFAULT 'mail' COMMENT '' AFTER `host_smtp`,
ADD COLUMN `host_pop` VARCHAR(64) NULL DEFAULT 'mail' COMMENT '' AFTER `host_imap`;

Changes in vexim:

for virtual users
/etc/exim4/conf.d/main/00_vexim_listmacrosdefs

### main/00_vexim_listmacrosdefs
#################################

# if you exim version < 4.83 , define macro below for enabling new
# 'headers_remove' behavior. See https://github.com/vexim/vexim2/pull/102 .
#OLD_HEADERS_REMOVE = yes

#hide mysql_servers = localhost::(/var/run/mysqld/mysqld.sock)/vexim/vexim/CHANGE

# domains
VEXIM_VIRTUAL_DOMAINS = SELECT DISTINCT domain FROM domains WHERE type = 'local' AND enabled = '1' AND domain = '${quote_mysql:$domain}' AND host_smtp = 'mail'
VEXIM_RELAY_DOMAINS = SELECT DISTINCT domain FROM domains WHERE type = 'relay'  AND domain = '${quote_mysql:$domain}' AND host_smtp = 'mail'
VEXIM_ALIAS_DOMAINS = SELECT DISTINCT alias FROM domainalias WHERE alias = '${quote_mysql:$domain}' AND host_smtp = 'mail'

# domains and relay networks
MAIN_LOCAL_DOMAINS = MAIN_LOCAL_DOMAINS : ${lookup mysql{VEXIM_VIRTUAL_DOMAINS}} : ${lookup mysql{VEXIM_ALIAS_DOMAINS}}
MAIN_RELAY_TO_DOMAINS = MAIN_RELAY_TO_DOMAINS : ${lookup mysql{VEXIM_RELAY_DOMAINS}}

# primary hostname
#MAIN_HARDCODE_PRIMARY_HOSTNAME=myhostname

# add vexim system user
#MAIN_TRUSTED_USERS = www-data

# enable TLS
#MAIN_TLS_ENABLE = true

# enable av scanner
#av_scanner = clamd:/var/run/clamav/clamd.ctl

# use spamassassing
#spamd_address = 127.0.0.1 783

# validation of sending mailserver
#CHECK_RCPT_REVERSE_DNS = true
#CHECK_RCPT_SPF = true

# If the local-part suffix is used, mails to user+whatevertext@example.org will be delivered to user@example.org
# Comment this line if you want to disable it, instead of + you can use a different separator.
VEXIM_LOCALPART_SUFFIX = +*

CHECK_RCPT_LOCAL_ACL_FILE = /etc/exim4/vexim-acl-check-rcpt.conf
CHECK_DATA_LOCAL_ACL_FILE = /etc/exim4/vexim-acl-check-content.conf

for mailman i create subdomains 'lists.*' and have a config for that:
/etc/exim4/conf.d/main/00_mailman

# Home dir for your Mailman installation -- aka Mailman's prefix
# directory.
MAILMAN_HOME=/var/lib/mailman
MAILMAN_WRAP=MAILMAN_HOME/mail/mailman

# User and group for Mailman, should match your --with-mail-gid
# switch to Mailman's configure script.
MAILMAN_USER=list
MAILMAN_GROUP=daemon
#MY_IP=x.x.x.x

MM_DOMAINS = SELECT DISTINCT domain FROM domains WHERE type = 'local' AND enabled = '1' AND domain LIKE 'lists.%' AND domain = '${quote_mysql:$domain}' AND host_smtp = 'mail'
domainlist mm_domains=${lookup mysql{MM_DOMAINS}}
MAILMAN_LISTCHK=MAILMAN_HOME/lists/${lc::$local_part}/config.pck

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions