sys4/automx

macro in [service]server

Closed this issue · 3 comments

Is it possible to rewrite the servers (imap/pop3/smtp servers) based on macros or variables?

I would like to be able to rewrite the servers to reflect the domain name of the email address. foo@bar.org would give smtp.bar.og, foo@example.com would return smtp.example.com

Is it possible to rewrite the servers (imap/pop3/smtp servers) based on macros or variables?

I would like to be able to rewrite the servers to reflect the domain name of the email address. foo@bar.org would give smtp.bar.og, foo@example.com would return smtp.example.com


Reply to this email directly or view it on GitHub.

Maybe you could use the script backend and test a little bit with it


#!/bin/bash

email=$1
domain=$(echo $email | cut -d "@" -f2)

echo $domain
——————————————————————————

Don’t know. Maybe like this…

Kind regards

-Christian Rößner

[*] sys4 AG

http://sys4.de, +49 (89) 30 90 46 64
Franziskanerstraße 15, 81669 München

Sitz der Gesellschaft: München, Amtsgericht München: HRB 199263
Vorstand: Patrick Ben Koetter, Axel von der Ohe, Marc Schiffbauer
Aufsichtsratsvorsitzender: Florian Kirstein

diff --git a/src/automx/config.py b/src/automx/config.py
index 1dd791f..2fa62ef 100644
--- a/src/automx/config.py
+++ b/src/automx/config.py
@@ -639,7 +639,7 @@ class Config(object, ConfigParser.RawConfigParser):
                 opt = service + "_server"
                 result = self.__expand_vars(self.get(section, opt))

-                proto_settings[opt] = result
+                proto_settings[opt] = self.__replace_makro(result)

             if self.has_option(section, service + "_port"):
                 opt = service + "_port"

This change makes the static config work with macros in the server part of the automx.conf
smtp.%d gets translated to smtp.example.com

Thanks. I have included this fix. Will be merged in a moment.