[GH-ISSUE #11] Feature: Allow setting of global domain aliases #12

Closed
opened 2026-02-26 09:35:06 +03:00 by kerem · 17 comments
Owner

Originally created by @szlwzl on GitHub (Mar 5, 2012).
Original GitHub issue: https://github.com/opensolutions/ViMbAdmin/issues/11

I'd like to be able to set a domain alias so that we don't need to setup a new alias for each individual address.

ANY@example2.com is forwarded to ANY@example.com

I believe that this will require a new table or updates to the db schema and /etc/postfix/mysql/*.cf to reflect which are whole domain aliases and which are just single email aliases.

Originally created by @szlwzl on GitHub (Mar 5, 2012). Original GitHub issue: https://github.com/opensolutions/ViMbAdmin/issues/11 I'd like to be able to set a domain alias so that we don't need to setup a new alias for each individual address. ANY@example2.com is forwarded to ANY@example.com I believe that this will require a new table or updates to the db schema and /etc/postfix/mysql/*.cf to reflect which are whole domain aliases and which are just single email aliases.
kerem 2026-02-26 09:35:06 +03:00
  • closed this issue
  • added the
    feature
    label
Author
Owner

@barryo commented on GitHub (Mar 6, 2012):

This would indeed be a nice addition.

Currently we support domain aliases of the form:

@example.com -> an-address@example.net

which will forward all mail to @example.com to the specified address. What you're asking is a one to one mapping such that x@example.com will goto x@example.net for any value of x.

This could be accomplished programatically but, as you say, Postfix seems to support this via virtual_alias_domains. Have you come across any complete documentation of how this is done via Postfix / MySQL?

Ideally, and preferably, I would like to see this as just another alias entry such as:

@example.com -> @example.net

as it's not dissimilar to the example at the top of my reply.

If you have a concrete example / how to / documentation of how this works in Postfix please provide references. Otherwise I'll try and put some time aside to dig into it myself.

<!-- gh-comment-id:4340938 --> @barryo commented on GitHub (Mar 6, 2012): This would indeed be a nice addition. Currently we support domain aliases of the form: ``` @example.com -> an-address@example.net ``` which will forward all mail to `@example.com` to the specified address. What you're asking is a one to one mapping such that `x@example.com` will goto `x@example.net` for any value of `x`. This could be accomplished programatically but, as you say, Postfix seems to support this via _virtual_alias_domains_. Have you come across any complete documentation of how this is done via Postfix / MySQL? Ideally, and preferably, I would like to see this as just another alias entry such as: ``` @example.com -> @example.net ``` as it's not dissimilar to the example at the top of my reply. If you have a concrete example / how to / documentation of how this works in Postfix please provide references. Otherwise I'll try and put some time aside to dig into it myself.
Author
Owner

@szlwzl commented on GitHub (Mar 6, 2012):

x@example.com will goto x@example.net for any value of x.

That's exactly right - we used allardsoft mail admin before it got too old and it has this feature as you describe.

My understanding is that postfix uses the below config to handle this.

virtual_alias_domains = BLAH

I believe that postfix does a lookup in the virtual_alias_domains then if it can't find it tries:

virtual_mailbox_domains

If this works then the mail is delivered. The problem is that a domain cannot be listed in queries returned by both virtual_mailbox_domains and virtual_alias_domains so would either need to set a flag in the DB that this is a full domain alias or update the queries within the relevant files. I've been experimenting with things like the following in mysql-virtual_domain_forwardings.cf.

query = select SUBSTRING(address,LOCATE('@',address)+1) as goto from alias where address='*@%s'

And this in mysql_virtual_domains.cf:

query = SELECT domain AS virtual FROM domain WHERE domain='%s' AND backupmx = '0' AND active = '1' AND domain NOT IN (select SUBSTRING(address,LOCATE('@',address)+1) as goto from alias where address='*@%s')

I haven't got it working yet but this gives an idea of how I think it would work. I'm considering creating a view in mysql to avoid doing anything too complex with the .cf files. Will have a go and let you know how it goes.

<!-- gh-comment-id:4342295 --> @szlwzl commented on GitHub (Mar 6, 2012): ``` x@example.com will goto x@example.net for any value of x. ``` That's exactly right - we used allardsoft mail admin before it got too old and it has this feature as you describe. My understanding is that postfix uses the below config to handle this. ``` virtual_alias_domains = BLAH ``` I believe that postfix does a lookup in the virtual_alias_domains then if it can't find it tries: ``` virtual_mailbox_domains ``` If this works then the mail is delivered. The problem is that a domain cannot be listed in queries returned by both virtual_mailbox_domains and virtual_alias_domains so would either need to set a flag in the DB that this is a full domain alias or update the queries within the relevant files. I've been experimenting with things like the following in mysql-virtual_domain_forwardings.cf. ``` query = select SUBSTRING(address,LOCATE('@',address)+1) as goto from alias where address='*@%s' ``` And this in mysql_virtual_domains.cf: query = SELECT domain AS virtual FROM domain WHERE domain='%s' AND backupmx = '0' AND active = '1' AND domain NOT IN (select SUBSTRING(address,LOCATE('@',address)+1) as goto from alias where address='*@%s') I haven't got it working yet but this gives an idea of how I think it would work. I'm considering creating a view in mysql to avoid doing anything too complex with the .cf files. Will have a go and let you know how it goes.
Author
Owner

@szlwzl commented on GitHub (Mar 7, 2012):

I've got this working by using *@domain2.com aliasing to *@domain.com and then doing some queries in the mysql/postfix files. Will try and post a howto soon to the wiki.

<!-- gh-comment-id:4380546 --> @szlwzl commented on GitHub (Mar 7, 2012): I've got this working by using *@domain2.com aliasing to *@domain.com and then doing some queries in the mysql/postfix files. Will try and post a howto soon to the wiki.
Author
Owner

@szlwzl commented on GitHub (Mar 7, 2012):

Added detail into https://github.com/opensolutions/ViMbAdmin/wiki/Config-Files-for-full-domain-aliasing

<!-- gh-comment-id:4380942 --> @szlwzl commented on GitHub (Mar 7, 2012): Added detail into https://github.com/opensolutions/ViMbAdmin/wiki/Config-Files-for-full-domain-aliasing
Author
Owner

@barryo commented on GitHub (Mar 8, 2012):

Great, thanks for that. I'll review (probably next week or the week after) and see if I can make integration into the UI obvious.

<!-- gh-comment-id:4386442 --> @barryo commented on GitHub (Mar 8, 2012): Great, thanks for that. I'll review (probably next week or the week after) and see if I can make integration into the UI obvious.
Author
Owner

@dexterd commented on GitHub (Mar 12, 2012):

Thanks for the guide. One notice - in mysql-virtual_domain_forwardings.cf, 'query=' line, content ends with $ i.e. not all text is visible.

<!-- gh-comment-id:4451050 --> @dexterd commented on GitHub (Mar 12, 2012): Thanks for the guide. One notice - in mysql-virtual_domain_forwardings.cf, 'query=' line, content ends with $ i.e. not all text is visible.
Author
Owner

@szlwzl commented on GitHub (Mar 12, 2012):

Doh! That's the important one as well, have updated the page now

<!-- gh-comment-id:4451424 --> @szlwzl commented on GitHub (Mar 12, 2012): Doh! That's the important one as well, have updated the page now
Author
Owner

@dexterd commented on GitHub (Mar 16, 2012):

Sorry for bothering, similar problem is with 'proxy_read_maps =' line.
Also, 'hosts = 127.0.0.1' option is not present in all .cf files. Is that intended?

<!-- gh-comment-id:4539242 --> @dexterd commented on GitHub (Mar 16, 2012): Sorry for bothering, similar problem is with 'proxy_read_maps =' line. Also, 'hosts = 127.0.0.1' option is not present in all .cf files. Is that intended?
Author
Owner

@szlwzl commented on GitHub (Mar 16, 2012):

Thanks for that - it should be updated now.

On 16 March 2012 13:03, dexterd
reply@reply.github.com
wrote:

Sorry for bothering, similar problem is with 'proxy_read_maps =' line.
Also, 'hosts = 127.0.0.1' option is not present in all .cf files. Is that intended?


Reply to this email directly or view it on GitHub:
https://github.com/opensolutions/ViMbAdmin/issues/11#issuecomment-4539242

<!-- gh-comment-id:4539332 --> @szlwzl commented on GitHub (Mar 16, 2012): Thanks for that - it should be updated now. On 16 March 2012 13:03, dexterd reply@reply.github.com wrote: > Sorry for bothering, similar problem is with 'proxy_read_maps =' line. > Also, 'hosts = 127.0.0.1' option is not present in all .cf files. Is that intended? > > --- > > Reply to this email directly or view it on GitHub: > https://github.com/opensolutions/ViMbAdmin/issues/11#issuecomment-4539242
Author
Owner

@click commented on GitHub (Mar 16, 2012):

I pulled a few SQL-selects for handling different scenarios from various sources and used it with the original implementation of postfixadmin (with slight modifications), combined with map-handling in main.cf
Not sure how much of this has already been implemented, so I'll just list the queries and their use...


-- handle relay-accepted domains (secondary MX pointers, anyone?)
SELECT domain FROM domain WHERE domain='%s' and backupmx = '1'

-- handle virtual alias domain
SELECT goto FROM alias,alias_domain WHERE alias_domain.alias_domain = '%d' and alias.address = CONCAT('%u', '@', alias_domain.target_domain) AND alias.active = 1 AND alias_domain.active='1'

; -- handle catch-all settings of target-domain
SELECT goto FROM alias,alias_domain WHERE alias_domain.alias_domain = '%d' and alias.address = CONCAT('@', alias_domain.target_domain) AND alias.active = 1 AND alias_domain.active='1'

-- handle virtual alias domain mailboxes
SELECT maildir FROM mailbox,alias_domain WHERE alias_domain.alias_domain = '%d' and mailbox.username = CONCAT('%u', '@', alias_domain.target_domain) AND mailbox.active = 1 AND alias_domain.active='1'

-- handle virtual aliases
SELECT goto FROM alias WHERE address='%s' AND active = '1'

-- handle virtual domain
SELECT domain FROM domain WHERE domain='%s' AND backupmx = '0' AND active = '1'

-- handle virtual mailbox
SELECT maildir FROM mailbox WHERE username='%s' AND active = '1'

-- handle virtual mailbox limit
SELECT quota FROM mailbox WHERE username='%s' AND active = '1'

As said before, some of these queries already exists in some way or form in the application/setup, but I hope this helps a bit at least. Can't wait for having this as a full alternative to postfixadmin, with all the bells and whistles implemented :)
For me, the relay-domains (backupmx) query is crucial for using failover-systems etc. at least - most probably already implemented, but worth commenting... :)

<!-- gh-comment-id:4547068 --> @click commented on GitHub (Mar 16, 2012): I pulled a few SQL-selects for handling different scenarios from various sources and used it with the original implementation of postfixadmin (with slight modifications), combined with map-handling in main.cf Not sure how much of this has already been implemented, so I'll just list the queries and their use... ``` SQL -- handle relay-accepted domains (secondary MX pointers, anyone?) SELECT domain FROM domain WHERE domain='%s' and backupmx = '1' -- handle virtual alias domain SELECT goto FROM alias,alias_domain WHERE alias_domain.alias_domain = '%d' and alias.address = CONCAT('%u', '@', alias_domain.target_domain) AND alias.active = 1 AND alias_domain.active='1' ; -- handle catch-all settings of target-domain SELECT goto FROM alias,alias_domain WHERE alias_domain.alias_domain = '%d' and alias.address = CONCAT('@', alias_domain.target_domain) AND alias.active = 1 AND alias_domain.active='1' -- handle virtual alias domain mailboxes SELECT maildir FROM mailbox,alias_domain WHERE alias_domain.alias_domain = '%d' and mailbox.username = CONCAT('%u', '@', alias_domain.target_domain) AND mailbox.active = 1 AND alias_domain.active='1' -- handle virtual aliases SELECT goto FROM alias WHERE address='%s' AND active = '1' -- handle virtual domain SELECT domain FROM domain WHERE domain='%s' AND backupmx = '0' AND active = '1' -- handle virtual mailbox SELECT maildir FROM mailbox WHERE username='%s' AND active = '1' -- handle virtual mailbox limit SELECT quota FROM mailbox WHERE username='%s' AND active = '1' ``` As said before, some of these queries already exists in some way or form in the application/setup, but I hope this helps a bit at least. Can't wait for having this as a full alternative to postfixadmin, with all the bells and whistles implemented :) For me, the relay-domains (backupmx) query is crucial for using failover-systems etc. at least - most probably already implemented, but worth commenting... :)
Author
Owner

@dexterd commented on GitHub (Apr 4, 2012):

Do we need "query = ..." line changes in config files after vimbadmin upgrade(from 2.0.8 -> 2.1.0)? It's been mentioned that database migration is needed ...

<!-- gh-comment-id:4956457 --> @dexterd commented on GitHub (Apr 4, 2012): Do we need "query = ..." line changes in config files after vimbadmin upgrade(from 2.0.8 -> 2.1.0)? It's been mentioned that database migration is needed ...
Author
Owner

@barryo commented on GitHub (Apr 4, 2012):

You only need to update the 'query =' line of the SQL configuration files if you want to use the access restriction. That said, I have just noticed an issue in that we forgot to allow for SMPT. Expect V2.1.1 tomorrow :(

See: https://github.com/opensolutions/ViMbAdmin/wiki/Update-Instructions for details.

PS: The best place for this kind of query is the mailing list.

<!-- gh-comment-id:4959777 --> @barryo commented on GitHub (Apr 4, 2012): You only need to update the 'query =' line of the SQL configuration files if you want to use the access restriction. That said, I have just noticed an issue in that we forgot to allow for SMPT. Expect V2.1.1 tomorrow :( See: https://github.com/opensolutions/ViMbAdmin/wiki/Update-Instructions for details. PS: The best place for this kind of query is the mailing list.
Author
Owner

@nysander commented on GitHub (Jan 23, 2013):

any progress in this topic?

<!-- gh-comment-id:12596433 --> @nysander commented on GitHub (Jan 23, 2013): any progress in this topic?
Author
Owner

@rodehoed commented on GitHub (Feb 21, 2014):

Dear admin,

Are there any updates about this feature? Most links refered in this post are non existing.

Regards,
Rodehoed

<!-- gh-comment-id:35725638 --> @rodehoed commented on GitHub (Feb 21, 2014): Dear admin, Are there any updates about this feature? Most links refered in this post are non existing. Regards, Rodehoed
Author
Owner
<!-- gh-comment-id:35725866 --> @barryo commented on GitHub (Feb 21, 2014): No updates but the corrected links above are now: - https://github.com/opensolutions/ViMbAdmin/wiki/V2---Config-Files-for-full-domain-aliasing - https://github.com/opensolutions/ViMbAdmin/wiki/V2---Update-Instructions
Author
Owner

@barryo commented on GitHub (Feb 21, 2014):

@rodehoed - If this is something you really need and are prepared to sponsor, see commercial support at:

http://www.vimbadmin.net/support.php

<!-- gh-comment-id:35725934 --> @barryo commented on GitHub (Feb 21, 2014): @rodehoed - If this is something you really need and are prepared to sponsor, see commercial support at: http://www.vimbadmin.net/support.php
Author
Owner

@digitalresistor commented on GitHub (Apr 18, 2014):

Since this post only applies to ViMbAdmin V2 and I needed this functionality for a client, I updated the SQL required to be Version 3 compatible.

Please see: https://gist.github.com/bertjwregeer/11055147 for more information, including Dovecot configuration to allow a user to login using either the canonical domain or the alias domain.

Hopefully this helps other people attempting to implement this.

<!-- gh-comment-id:40827455 --> @digitalresistor commented on GitHub (Apr 18, 2014): Since this post only applies to ViMbAdmin V2 and I needed this functionality for a client, I updated the SQL required to be Version 3 compatible. Please see: https://gist.github.com/bertjwregeer/11055147 for more information, including Dovecot configuration to allow a user to login using either the canonical domain or the alias domain. Hopefully this helps other people attempting to implement this.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/ViMbAdmin-opensolutions#12
No description provided.