diff --git a/etc/alternc/templates/postfix/myalias.cf b/etc/alternc/templates/postfix/myalias.cf index cc62b80b..4bad9721 100644 --- a/etc/alternc/templates/postfix/myalias.cf +++ b/etc/alternc/templates/postfix/myalias.cf @@ -6,6 +6,6 @@ user = %%db_mail_user%% password = %%db_mail_pwd%% hosts =%%dbhost%% dbname = %%dbname%% -query = select concat( if(isnull(mailbox.id), '', concat(concat(address.address,'@',domaines.domaine), '\n')), recipient.recipients ) from recipient join address on address.id = recipient.address_id left outer join mailbox on mailbox.address_id = address.id join domaines on domaines.id = address.domain_id where concat(address.address,'@',domaines.domaine)='%s'; +query = select alias from alias_view where mail='%s'; diff --git a/install/alternc.install b/install/alternc.install index 2f065e51..5e112be2 100644 --- a/install/alternc.install +++ b/install/alternc.install @@ -330,6 +330,12 @@ if [ -x /usr/sbin/locale-gen ] ; then fi fi +####################################################################### +#populate alternc database with the mailname used by postfix to send mail for each vhost +# +mailname=`cat /etc/mailname` +mysql_query "update table variable SET value="$mailname" where name='mailname_bounce';" + ####################################################################### # Save installed files to check them during next install # diff --git a/install/mysql.sql b/install/mysql.sql index 97fe0432..1da64057 100644 --- a/install/mysql.sql +++ b/install/mysql.sql @@ -646,7 +646,7 @@ CREATE TABLE IF NOT EXISTS `cron` ( -- --- Structure de la vue `dovecot-view` +-- Structure de la vue `dovecot_view` -- CREATE OR REPLACE VIEW `dovecot_view` AS @@ -662,3 +662,18 @@ from ((`mailbox` join `address` on((`address`.`id` = `mailbox`.`address_id`))) join `domaines` on((`domaines`.`id` = `address`.`domain_id`))); +-- +-- Structure de la vue `alias_view` +-- + +CREATE OR REPLACE VIEW `alias_view` AS +select concat(`address`.`address`,'@',`domaines`.`domaine`) AS `mail`, +concat(if(isnull(`mailbox`.`id`),'',concat(concat(`address`.`address`,'@',`domaines`.`domaine`),'\n')),`recipient`.`recipients`) AS `alias` +from (((`recipient` join `address` on((`address`.`id` = `recipient`.`address_id`))) +left join `mailbox` on((`mailbox`.`address_id` = `address`.`id`))) +join `domaines` on((`domaines`.`id` = `address`.`domain_id`))) +union +select distinct concat(`m`.`login`,'@',`v`.`value`) AS `mail`, +`m`.`mail` AS `alias` +from ((`membres` `m` join `variable` `v`) join `domaines` `d`) +where (`v`.`name` = 'mailname_bounce');