Current time: 12-24-2024, 05:03 AM Hello There, Guest! (LoginRegister)


Post Reply 
Domain alias mail forward ?
Author Message
GaRCieLD Offline
Junior Member
*

Posts: 15
Joined: Jun 2007
Reputation: 0
Post: #1
Domain alias mail forward ?
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!
11-14-2007 02:26 AM
Find all posts by this user Quote this message in a reply
rbtux Offline
Moderator
*****
Moderators

Posts: 1,847
Joined: Feb 2007
Reputation: 33
Post: #2
RE: Domain alias mail forward ?
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...
11-14-2007 02:56 AM
Visit this user's website Find all posts by this user Quote this message in a reply
rbtux Offline
Moderator
*****
Moderators

Posts: 1,847
Joined: Feb 2007
Reputation: 33
Post: #3
RE: Domain alias mail forward ?
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!
(This post was last modified: 11-14-2007 05:19 AM by rbtux.)
11-14-2007 05:16 AM
Visit this user's website Find all posts by this user Quote this message in a reply
GaRCieLD Offline
Junior Member
*

Posts: 15
Joined: Jun 2007
Reputation: 0
Post: #4
RE: Domain alias mail forward ?
wow! Thanks!!

I will try now!!
11-14-2007 05:30 AM
Find all posts by this user Quote this message in a reply
GaRCieLD Offline
Junior Member
*

Posts: 15
Joined: Jun 2007
Reputation: 0
Post: #5
RE: Domain alias mail forward ?
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!!!
11-14-2007 06:06 AM
Find all posts by this user Quote this message in a reply
rbtux Offline
Moderator
*****
Moderators

Posts: 1,847
Joined: Feb 2007
Reputation: 33
Post: #6
RE: Domain alias mail forward ?
i would do a file for each domain...


your welcome (remember the reputation^^Wink)
11-14-2007 06:08 AM
Visit this user's website Find all posts by this user Quote this message in a reply
jmeyerdo Offline
Junior Member
*

Posts: 173
Joined: Oct 2007
Reputation: 2
Post: #7
RE: Domain alias mail forward ?
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
02-14-2008 03:39 AM
Find all posts by this user Quote this message in a reply
rbtux Offline
Moderator
*****
Moderators

Posts: 1,847
Joined: Feb 2007
Reputation: 33
Post: #8
RE: Domain alias mail forward ?
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...
02-14-2008 03:47 AM
Visit this user's website Find all posts by this user Quote this message in a reply
jmeyerdo Offline
Junior Member
*

Posts: 173
Joined: Oct 2007
Reputation: 2
Post: #9
RE: Domain alias mail forward ?
rbtux Wrote:If you got specific problems just ask...
Thank you.
I will do my very best tomorrow... Wink
02-14-2008 04:21 AM
Find all posts by this user Quote this message in a reply
jmeyerdo Offline
Junior Member
*

Posts: 173
Joined: Oct 2007
Reputation: 2
Post: #10
RE: Domain alias mail forward ?
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
02-15-2008 03:41 AM
Find all posts by this user Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 3 Guest(s)