When I register on websites I use their domain in my email, for example serverfault.com@example.com. I'd like to file each domain into a separate IMAP folder using sieve and I've created the script below:
if envelope :regex "to" ["^(.*\\.uk)@", "^(.*\\.com)@", "^(.*\\.org)@"] {
set :lower "fromdomain" "${1}";
if string :is "${fromdomain}" "" {
keep;
} else {
fileinto "domains.${fromdomain}";
}
}
However, my server is configured to use '.' as the folder separator so this email would go into:
domains
serverfault
com <<<
instead of:
domains
serverfault.com <<<
As I'd be happy with "serverfault com" I've tried looking for a string replacement function, but sieve doesn't appear to have one. Straight concatenation i.e. serverfaultcom would get confusing.
I'd need all parts of the domain so that test.serverfault.com and serverfault.co.uk are filed separately.
Is there another trick that could do this, or something close?
The mail server is hosted on debian-jessie using Bytemark's Symbiosis admin tools.