-
Notifications
You must be signed in to change notification settings - Fork 276
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for multiple servers #12
base: master
Are you sure you want to change the base?
Conversation
Thank you for taking the time to submit the pull request. I've had a quick eye-ball of it, and nothing immediate is jumping out. |
There is one small todo, i don't have any idea how to solve it: |
DOCUMENTS/POSTFIX_CONF.txt
Outdated
@@ -13,12 +13,19 @@ postconf -m) Three main.cf variables are involved: | |||
|
|||
virtual_mailbox_domains = proxy:mysql:/etc/postfix/sql/mysql_virtual_domains_maps.cf | |||
virtual_alias_maps = | |||
proxy:mysql:/etc/postfix/sql/mysql_virtual_alias_maps.cf, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a reason why mysql_virtual_alias_maps.cf is listed first - an alias domain can "override" some aliases. To keep this working, mysql_virtual_alias_maps.cf needs to be the first in the list.
Why did you move it around?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason i remember was that recursive lookups failed.
e.g. some_mail@host aliases to webmaster@host
webmaster@host aliases to my_name@host
In the default settings this lookup failed.
Could you name a setting where this order of handling is needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I'm surprised that this fails because IIRC I have more than one "chained" alias ;-) - and I'm even more surprised that changing the order fixed it for you.
The setting that will probably break is:
- alias a@host -> foo@example.com
- alias a@otherhost -> bar@example.com
- alias b@otherhost -> b@example.com (and some other aliases that don't exist @host)
- alias domain host -> otherhost
The goal is: all mails that are sent to @host should be forwarded to the same address @Otherhost (if this address exists) - except a@ because the a@host alias overrides this.
Ok, i've done several changes:
The postcreation and postdeletion hook is only there because i followed the implementation of domains. I don't know if there is a need for server-post(creation|deletion)-scripts. I still dont get what problem the changed order in the virtual_alias_maps would cause. |
For the postfix-issue: I checked it with my local setup. You were right. I don't know what went wrong in my normal setup... |
I did one final change: The server tab is now only visible for super-admins. I thought of making only servers visible to non-global admins which are primary servers for their domain(s). I left the primary_mx column in the domain overview, maybe this is useful. If it is not, i'll remove it too. |
@@ -59,6 +59,9 @@ | |||
# set in __construct() | |||
protected $allowed_domains = false; | |||
|
|||
# array with the server list set in __construct() | |||
protected $allowed_servers = false; | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(sorry for the long delay!)
This is only used in DomainHandler, so it should be defined there. (If it's used by more *Handler classes in the future, PFAHandler would be ok.)
DOCUMENTS/POSTFIX_CONF.txt
Outdated
password = password | ||
hosts = localhost | ||
dbname = postfix | ||
query = SELECT address FROM server JOIN domain ON domain.primarymx = server.server WHERE (domain.domain = '%s' OR CONCAT('.', domain.domain) = '%s') AND domain.primarymx!='@@myhostname@@' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't the 'transport_maps'-query also include AND active = '1'
?
FWIW, I love this pull request, and are working on implementing it in my own mail-server setup.
29a9877
to
1371bd4
Compare
I've rebased all changes to comply with the new master status. You might want to recheck my implementations if they comply with your code style. I haven't done the adjustment @cboltz suggested to use the already available 'transport' field. |
config.inc.php
Outdated
@@ -523,6 +528,22 @@ function x_struct_admin_modify($struct) { | |||
// $CONF['domain_postdeletion_script']='sudo -u courier /usr/local/bin/postfixadmin-domain-postdeletion.sh'; | |||
$CONF['domain_postdeletion_script'] = ''; | |||
|
|||
// Optional | |||
// Script to run after creation of servers. | |||
// Not that this may fail if PHP is nun in "safe mode", or if |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not
or Note
?
config.inc.php
Outdated
|
||
// Optional | ||
// Script to run after deletion of servers. | ||
// Not that this may fail if PHP is nun in "safe mode", or if |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not
or Note
?
languages/bg.lang
Outdated
$PALANG['server_button'] = 'Add server'; # XXX | ||
$PALANG['server_create_error'] = 'Creating server %s failed'; # XXX | ||
$PALANG['server_edit_error'] = 'Modifying server %s failed'; # XXX | ||
$PALANG['server_store_success'] = 'The Server %s has successfully been added.'; # XXX |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just nitpicking: why is Server
uppercase here?
languages/bg.lang
Outdated
$PALANG['server_does_not_exist'] = 'The server %s does not exist.'; # XXX | ||
$PALANG['confirm_delete_server'] = 'Do you really want to delete the server %s?'; # XXX | ||
$PALANG['delete_server_domain_target'] = 'There are still domains, where this server is the primary one. Change them first'; # XXX | ||
$PALANG['server_updated'] = 'The Server %s was updated'; # XXX |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just nitpicking again :)
... and a few more places below
1371bd4
to
271bb09
Compare
I have updated this pull request to Postfixadmin v3. I haven't updated the language files yet, nor the postfix configuration script. |
$firstline=''; | ||
$firstline=exec($command,$output,$retval); | ||
if (0!=$retval) { | ||
error_log("Running $command yielded return value=$retval, first line of output=$firstline"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not (for example) just json_encode($output) at the end of this message, rather than restricting it to the first line ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be honest, I've just copied this piece of code from model/DomainHandler.php#L292
I could change that in my pull request, but I guess it should then be changed in all model handlers.
....
By that - do you mean whatever config is needed for Postfix to use this functionality ? |
In the previous version of my pull request I changed the POSTFIX_CONF.txt to support the multiple server feature. But I think my changes were not compatible with the standard-setup. |
Any chance you could rebase your branch onto master and add some basic documentation - e..g what changes are needed to the database queries postfix uses for this to be in a usable state to merge in? |
@Janfred: It is possible to rebase your PR? |
I'll add it to my todo-List for when I have a bit time to spare. |
@Janfred Did you manage to rebase your PR? Would be a really nice feature to have :-) |
Add support for multiple servers.
Useful for hot standby or backup systems with replicated databases.
The main problem is that, if you want to have a backup mx, you need to copy all mailbox setting changes you make on the first system to the second one.
With this new feature you can just replicate your database and use it for both, the primary and the secondary mailserver.
You can also do load balancing by sending one domain to the first and an other domain to the second mailserver as primary.