inital merge of lenix's patch for domain aliasing; I think list-virtual.php needs some attention, but I've run out of time right now; upgrade.php has been updated to create the tables correctly (tested on pgsql and mysql); functionality or php scripts not tested yet
Where you chose to store the .cf files doesn't really matter, but they will
have database passwords stored in plain text so they should be readable only
@ -35,22 +40,35 @@ user = postfix
password = password
hosts = localhost
dbname = postfix
query = SELECT goto FROM alias WHERE address='%s' AND active = '1'
query = SELECT goto FROM alias WHERE address='%s' AND active = '1'
#expansion_limit = 100
mysql_virtual_alias_domain_maps.cf:
user = postfix
password = password
hosts = localhost
dbname = postfix
query = 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
mysql_virtual_alias_domain_catchall_maps.cf:
# handles catch-all settings of target-domain
user = postfix
password = password
hosts = localhost
dbname = postfix
query = SELECT goto FROM alias,alias_domain WHERE alias_domain.alias_domain = '%d' and alias.address = CONCAT('@', alias_domain.target_domain) AND alias.active = 1
mysql_virtual_domains_maps.cf:
user = postfix
password = password
hosts = localhost
dbname = postfix
query = SELECT domain FROM domain WHERE domain='%u'
query = SELECT domain FROM domain WHERE domain='%s' AND active = '1'
#query = SELECT domain FROM domain WHERE domain='%s'
#optional query to use when relaying for backup MX
#query = SELECT domain FROM domain WHERE domain='%s' AND backupmx = '0' AND active = '1'
#expansion_limit = 100
mysql_virtual_mailbox_maps.cf:
user = postfix
password = password
@ -59,6 +77,13 @@ dbname = postfix
query = SELECT CONCAT(domain,'/',maildir) FROM mailbox WHERE username='%s' AND active = '1'
#expansion_limit = 100
mysql_virtual_alias_domain_mailbox_maps.cf:
user = postfix
password = password
hosts = localhost
dbname = postfix
query = SELECT CONCAT(domain,'/',maildir) FROM mailbox,alias_domain WHERE alias_domain.alias_domain = '%d' and mailbox.username = CONCAT('%u', '@', alias_domain.target_domain) AND mailbox.active = 1
-------------------------
More information - HowTo docs that use PostfixAdmin
$PALANG['pCreate_alias_domain_success'] = 'The domain alias has been added to the alias domain table!';
$PALANG['pCreate_alias_welcome'] = 'Create a new alias for your domain.';
$PALANG['pCreate_alias_address'] = 'Alias';
$PALANG['pCreate_alias_address_text_error1'] = '<br /><span class="error_msg">The ALIAS is not valid!</span>';
@ -98,7 +118,7 @@ $PALANG['pCreate_alias_goto_text'] = 'Where the mail needs to be sent to.';
$PALANG['pCreate_alias_goto_text_error'] = 'Where the email needs to go.<br /><span class="error_msg">The TO is not valid!</span>';
$PALANG['pCreate_alias_result_error'] = '<span class="error_msg">Unable to add the alias to the alias table!</span>';
$PALANG['pCreate_alias_result_success'] = 'The alias has been added to the alias table!';
$PALANG['pCreate_alias_catchall_text'] = 'To create a catch-all use an "*" as alias.<br />For domain to domain forwarding use "*@domain.tld" as to.';
$PALANG['pCreate_alias_catchall_text'] = 'To create a catch-all use an "*" as alias.'; # XXX don't propagate usage of *@target-domain.com for domain-aliasing any longer
$PALANG['pEdit_alias_welcome'] = 'Edit an alias for your domain.<br />One entry per line.';
@ -72,12 +72,54 @@ if (!check_owner(authentication_get_username(), $fDomain)) {
exit(0);
}
# Alias-Domains
# first try to get a list of other domains pointing
# to this currently chosen one (aka. alias domains)
$query = "SELECT $table_alias_domain.alias_domain,$table_alias_domain.target_domain,$table_alias_domain.modified,$table_alias_domain.active FROM $table_alias_domain WHERE target_domain='$fDomain' ORDER BY $table_alias_domain.alias_domain LIMIT $fDisplay, $page_size";
if ('pgsql'==$CONF['database_type'])
{
$query = "SELECT alias_domain,target_domain,extract(epoch from modified) as modified,active FROM $table_alias_domain WHERE target_domain='$fDomain' ORDER BY alias_domain LIMIT $page_size OFFSET $fDisplay";
# now let's see if the current domain itself is an alias for another domain
$query = "SELECT $table_alias_domain.alias_domain,$table_alias_domain.target_domain,$table_alias_domain.modified,$table_alias_domain.active FROM $table_alias_domain WHERE alias_domain='$fDomain'";
if ('pgsql'==$CONF['database_type'])
{
$query = "SELECT alias_domain,target_domain,extract(epoch from modified) as modified,active FROM $table_alias_domain WHERE alias_domain='$fDomain'";
$query = "SELECT $table_alias.address,$table_alias.goto,$table_alias.modified,$table_alias.active FROM $table_alias LEFT JOIN $table_mailbox ON $table_alias.address=$table_mailbox.username WHERE $table_alias.domain='$fDomain' AND $table_mailbox.maildir IS NULL ORDER BY $table_alias.address LIMIT $fDisplay, $page_size";
if ('pgsql'==$CONF['database_type'])
{
$query = "SELECT address,goto,extract(epoch from modified) as modified,active FROM $table_alias WHERE domain='$fDomain' AND NOT EXISTS(SELECT 1 FROM $table_mailbox WHERE username=$table_alias.address) ORDER BY address LIMIT $page_size OFFSET $fDisplay";