ispCP - Board - Support
Domain alias mail forward ? - Printable Version

+- ispCP - Board - Support (http://www.isp-control.net/forum)
+-- Forum: ispCP Omega Support Area (/forum-30.html)
+--- Forum: Usage (/forum-34.html)
+--- Thread: Domain alias mail forward ? (/thread-1781.html)

Pages: 1 2


Domain alias mail forward ? - GaRCieLD - 11-14-2007 02:26 AM

Hello,

When I create a domain alias for some domain and then edit the alias, there is an option called "Enable Forward - yes/no" and "Forward to URL", but I don't know how to use it.

For example, I want:

domain1.com
with an alias domain1_alias.com

and I want that all the mails to info@domain1_alias.com go to the same acount in the main domain (info@domain1.com in the example)

This is the way? or can I make this hand-make? any advice?

Thanks!


RE: Domain alias mail forward ? - rbtux - 11-14-2007 02:56 AM

i don't know atm if ispcp supports this...


postfix can handle the without any problems (of course;-)):
if someone can confirm that its not possible with ispcp I can write a small how to do that... Not a big trick...


RE: Domain alias mail forward ? - rbtux - 11-14-2007 05:16 AM

OK I now checked that... I could not find a option in the nice clicky gui ;-)

So handwork:

1. Add mysql user
Quote:> mysql -u root -p mysql

mysql> GRANT SELECT ON ispcp.* to 'ispcp_postfix'@'localhost' identified by 'mypass';
mysql> FLUSH PRIVILEGES;
mysql> quit;

2. Install Postfic mysql package
Quote:apt-get install postfix-mysql


3. Create Postfix mysql map
Create /etc/postfix/domainalias.mysql with the following content:
NOTE: Replace NORMAL_DOMAIN and ALIAS_DOMAIN (f.e. domain1.com and domain1_alias.com)
Quote:user=ispcp_postfix
password=mypass
dbname=ispcp
query = SELECT concat(mail_users.mail_acc,'@', domain.domain_name) as forw_addr FROM mail_users inner join domain on mail_users.domain_id = domain.domain_id WHERE concat(mail_users.mail_acc,'@', 'ALIAS_DOMAIN') = '%s' and domain.domain_name='NORMAL_DOMAIN' and (mail_type='normal_mail' or mail_type='normal_forward');
hosts = 127.0.0.1


4. Alter postfix main.cf
Alter the line virtual_alias_maps of /etc/postfix/main.cf that it looks like:
Quote:virtual_alias_maps = hash:/etc/postfix/ispcp/aliases, mysql:/etc/postfix/domainalias.mysql

5. postfix reload
Quote:> postfix reload


There is another possibility with an hash-file containing @domain1_alias.com @domain1.com. But this solution would accept mails for users the don't exist in @domain1.com an bounce them later... Thats not nice!


RE: Domain alias mail forward ? - GaRCieLD - 11-14-2007 05:30 AM

wow! Thanks!!

I will try now!!


RE: Domain alias mail forward ? - GaRCieLD - 11-14-2007 06:06 AM

All works without problem...

I just changed localhost to 127.0.0.1

Code:
mysql> GRANT SELECT ON ispcp.* to 'ispcp_postfix'@'127.0.0.1' identified by 'mypass';

If I want to do this with more than one domain is better to make another domainalias-2.mysql or better to just put in the WHERE clause?
Code:
WHERE concat(mail_users.mail_acc,'@', 'ALIAS_DOMAIN') = '%s' and domain.domain_name='NORMAL_DOMAIN' and (mail_type='normal_mail' or mail_type='normal_forward')

OR

concat(mail_users.mail_acc,'@', 'ALIAS_DOMAIN_2') = '%s' and domain.domain_name='NORMAL_DOMAIN' and (mail_type='normal_mail' or mail_type='normal_forward');

Thanks rbtux!!!


RE: Domain alias mail forward ? - rbtux - 11-14-2007 06:08 AM

i would do a file for each domain...


your welcome (remember the reputation^^Wink)


RE: Domain alias mail forward ? - jmeyerdo - 02-14-2008 03:39 AM

Hi all, hi rbtux!

I found this thread while searching for "mysql and postfix".

When using the standard db-files/hashes from "/etc/postfix/ispcp/" the server feels responsible for every ispcp-domain on the server - even for domains without any email-accounts, isn't it?!

Because I moved from Courier to Dovecot already I want to switch from the hash-files to complete mysql-driven configuration now. As I can see the configuration-tipps from this thread are for a special requirement only.

Has anybody build mysql-configuration-files available for replacing the following files:
Code:
virtual_mailbox_domains = hash:/etc/postfix/ispcp/domains
virtual_mailbox_maps    = hash:/etc/postfix/ispcp/mailboxes
virtual_alias_maps      = hash:/etc/postfix/ispcp/aliases

Kind regards,
Jens


RE: Domain alias mail forward ? - rbtux - 02-14-2008 03:47 AM

not exactly... but this shouldn't be that hard...

I use something similar to get the recipient adresses for my mx servers (i don't use ispcp server to recieve e-mails directly)..

If you got specific problems just ask...


RE: Domain alias mail forward ? - jmeyerdo - 02-14-2008 04:21 AM

rbtux Wrote:If you got specific problems just ask...
Thank you.
I will do my very best tomorrow... Wink


RE: Domain alias mail forward ? - jmeyerdo - 02-15-2008 03:41 AM

Hi rbtux, hi all!

So, I did it today (with several cups of coffee and the help of my colleague).
While preparing the SQL-statements I noticed that the database-schema is not very good for this usage (in comparison with "standard" postfix-tables).
Especially it is very astonishing that the target-email for catchalls is stored in mail_acc but for all other email-configurations in mail_forward IMHO. Why this?!
For my usage I will add indizes to speed up the sql-selects soon.

Attached my postfix-mysql-files (please remove my comments and linebreaks in SQL before using!). Works fine for me. After confirmation of you as specialists I can add this to the dovecot-configuration-page in the WIKI if you want.

Code:
# transport_maps      = mysql:/etc/postfix/mysql_virtual_transport_maps.cf

user=ispcp_postfix
password=mypass
dbname=ispcp
query = select DISTINCT "ispcp-arpl:" from mail_users, domain
where mail_users.domain_id = domain.domain_id
   and CONCAT("ispcp-arpl.", domain.domain_name) = '%s'
   and mail_users.sub_id = 0
   and mail_users.status = "ok"
   and mail_users.mail_auto_respond != "_no_"
union
select DISTINCT "ispcp-arpl:" from mail_users, domain, subdomain
where mail_users.domain_id = domain.domain_id
   and subdomain.subdomain_id = mail_users.sub_id
   and CONCAT(CONCAT(CONCAT("ispcp-arpl.", subdomain.subdomain_name), "."), domain.domain_name) = '%s'
   and mail_users.status = "ok"
   and mail_users.mail_auto_respond != "_no_"
union
select DISTINCT "ispcp-arpl:" from mail_users, domain_aliasses
where domain_aliasses.alias_id = mail_users.sub_id
   and CONCAT("ispcp-arpl.", domain_aliasses.alias_name) = '%s'
   and mail_users.status = "ok"
   and mail_users.mail_auto_respond != "_no_"



# virtual_mailbox_domains = mysql:/etc/postfix/mysql_virtual_domains_maps.cf

user=ispcp_postfix
password=mypass
dbname=ispcp
query = select DISTINCT domain.domain_name from mail_users, domain
where mail_users.domain_id = domain.domain_id
   and domain.domain_name = '%s'
   and mail_users.sub_id = 0
   and mail_users.status = "ok"
union
select DISTINCT CONCAT(CONCAT(subdomain.subdomain_name, "."), domain.domain_name) from mail_users, domain, subdomain
where mail_users.domain_id = domain.domain_id
   and subdomain.subdomain_id = mail_users.sub_id
   and CONCAT(CONCAT(subdomain.subdomain_name, "."), domain.domain_name) = '%s'
   and mail_users.status = "ok"
union
select DISTINCT domain_aliasses.alias_name from mail_users, domain_aliasses
where domain_aliasses.alias_id = mail_users.sub_id
   and domain_aliasses.alias_name = '%s'
   and mail_users.status = "ok"
  
# virtual_mailbox_maps    = mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf

user=ispcp_postfix
password=mypass
dbname=ispcp
query = select DISTINCT CONCAT(CONCAT(mail_users.mail_acc, "@"), domain.domain_name) from mail_users, domain
where mail_users.domain_id = domain.domain_id
   and CONCAT(CONCAT(mail_users.mail_acc, "@"), domain.domain_name) = '%s'
   and mail_users.mail_type = "normal_mail"
   and mail_users.status = "ok"
union
select DISTINCT CONCAT(CONCAT(CONCAT(mail_users.mail_acc, "@"),subdomain.subdomain_name, "."), domain.domain_name) from mail_users, domain, subdomain
where mail_users.domain_id = domain.domain_id
   and subdomain.subdomain_id = mail_users.sub_id
   and CONCAT(CONCAT(CONCAT(mail_users.mail_acc, "@"),subdomain.subdomain_name, "."), domain.domain_name) = '%s'
   and mail_users.mail_type = "subdom_mail"
   and mail_users.status = "ok"
union
select DISTINCT CONCAT(CONCAT(mail_users.mail_acc, "@"),domain_aliasses.alias_name) from mail_users, domain, domain_aliasses
where domain_aliasses.alias_id = mail_users.sub_id
   and CONCAT(CONCAT(mail_users.mail_acc, "@"),domain_aliasses.alias_name) = '%s'
   and mail_users.mail_type = "alias_mail"
   and mail_users.status = "ok"

  

# virtual_alias_maps      = mysql:/etc/postfix/mysql_virtual_alias_maps.cf


user=ispcp_postfix
password=mypass
dbname=ispcp
query =

# Postfaecher
select DISTINCT CONCAT(CONCAT(mail_users.mail_acc, "@"), domain.domain_name) from mail_users, domain
where mail_users.domain_id = domain.domain_id
   and CONCAT(CONCAT(mail_users.mail_acc, "@"), domain.domain_name) = '%s'
   and mail_users.mail_type = "normal_mail"
   and mail_users.status = "ok"
union
select DISTINCT CONCAT(CONCAT(CONCAT(mail_users.mail_acc, "@"),subdomain.subdomain_name, "."), domain.domain_name) from mail_users, domain, subdomain
where mail_users.domain_id = domain.domain_id
   and subdomain.subdomain_id = mail_users.sub_id
   and CONCAT(CONCAT(CONCAT(mail_users.mail_acc, "@"),subdomain.subdomain_name, "."), domain.domain_name) = '%s'
   and mail_users.mail_type = "subdom_mail"
   and mail_users.status = "ok"
union
select DISTINCT CONCAT(CONCAT(mail_users.mail_acc, "@"),domain_aliasses.alias_name) from mail_users, domain, domain_aliasses
where domain_aliasses.alias_id = mail_users.sub_id
   and CONCAT(CONCAT(mail_users.mail_acc, "@"),domain_aliasses.alias_name) = '%s'
   and mail_users.mail_type = "alias_mail"
   and mail_users.status = "ok"

# Weiterleitungen
union
select DISTINCT mail_users.mail_forward from mail_users, domain
where mail_users.domain_id = domain.domain_id
   and CONCAT(CONCAT(mail_users.mail_acc, "@"), domain.domain_name) = '%s'
   and mail_users.mail_type = "normal_forward"
   and mail_users.status = "ok"
union
select DISTINCT mail_users.mail_forward from mail_users, domain, subdomain
where mail_users.domain_id = domain.domain_id
   and subdomain.subdomain_id = mail_users.sub_id
   and CONCAT(CONCAT(CONCAT(mail_users.mail_acc, "@"),subdomain.subdomain_name, "."), domain.domain_name) = '%s'
   and mail_users.mail_type = "subdom_forward"
   and mail_users.status = "ok"
union
select DISTINCT mail_users.mail_forward from mail_users, domain, domain_aliasses
where domain_aliasses.alias_id = mail_users.sub_id
   and CONCAT(CONCAT(mail_users.mail_acc, "@"),domain_aliasses.alias_name) = '%s'
   and mail_users.mail_type = "alias_forward"
   and mail_users.status = "ok"

# Autoreplies
union
select DISTINCT CONCAT(CONCAT(CONCAT(mail_users.mail_acc, "@"), "ispcp-arpl."), domain.domain_name) from mail_users, domain
where mail_users.domain_id = domain.domain_id
   and CONCAT(CONCAT(mail_users.mail_acc, "@"), domain.domain_name) = '%s'
   and mail_users.mail_type = "normal_mail"
   and mail_users.status = "ok"
   and mail_users.mail_auto_respond != "_no_"
union
select DISTINCT CONCAT(CONCAT(CONCAT(CONCAT(mail_users.mail_acc, "@"), "ispcp-arpl."), subdomain.subdomain_name, "."), domain.domain_name) from mail_users, domain, subdomain
where mail_users.domain_id = domain.domain_id
   and subdomain.subdomain_id = mail_users.sub_id
   and CONCAT(CONCAT(CONCAT(mail_users.mail_acc, "@"),subdomain.subdomain_name, "."), domain.domain_name) = '%s'
   and mail_users.mail_type = "subdom_mail"
   and mail_users.status = "ok"
   and mail_users.mail_auto_respond != "_no_"
union
select DISTINCT CONCAT(CONCAT(CONCAT(mail_users.mail_acc, "@"),"ispcp-arpl."), domain_aliasses.alias_name) from mail_users, domain, domain_aliasses
where domain_aliasses.alias_id = mail_users.sub_id
   and CONCAT(CONCAT(mail_users.mail_acc, "@"),domain_aliasses.alias_name) = '%s'
   and mail_users.mail_type = "alias_mail"
   and mail_users.status = "ok"
   and mail_users.mail_auto_respond != "_no_"
  
# Catchalls
union
select mail_users.mail_acc from mail_users, domain
where mail_users.domain_id = domain.domain_id
   and CONCAT("@", domain.domain_name) = '%s'
   and mail_users.mail_type = "normal_catchall"
   and mail_users.status = "ok"
union
select mail_users.mail_acc from mail_users, domain, subdomain
where mail_users.domain_id = domain.domain_id
   and subdomain.subdomain_id = mail_users.sub_id
   and CONCAT(CONCAT(CONCAT("@" , subdomain.subdomain_name), "."), domain.domain_name) = '%s'
   and mail_users.mail_type = "subdom_catchall"
   and mail_users.status = "ok"
union
select mail_users.mail_acc from mail_users, domain_aliasses
where domain_aliasses.alias_id = mail_users.sub_id
   and CONCAT("@", domain_aliasses.alias_name) = '%s'
   and mail_users.mail_type = "alias_catchall"
   and mail_users.status = "ok"

Kind regards, Jens