-
Notifications
You must be signed in to change notification settings - Fork 102
V2 Config Files for full domain aliasing
Barry O'Donovan edited this page Feb 11, 2014
·
1 revision
Allow the use of whole domain redirection, ie all @domain2.com go to @domain.com and will only be accepted if the address exists in domain.com. The below config files also use amavisd for AV scanning and content filtering as well as patching the postfix source for quota usage.
To use this in ViMbAdmin just set an alias of *@domain2.com to *@domain.com
Welcome any feedback on the below.
The config files used are:
mysql-virtual_domain_forwardings.cf
user = <DB USER>
password = <PASSWORD>
dbname = <DB NAME>
query= SELECT SUBSTRING(goto,LOCATE('@',goto)) as goto FROM alias WHERE address='*@%d' AND 1 = (SELECT count(domain) FROM mailbox WHERE local_part='%u' AND domain =(SELECT SUBSTRING(goto,LOCATE('@',goto)+1) as goto FROM alias WHERE address='*@%d'))
hosts = 127.0.0.1
mysql-virtual_email2email.cf
user = <DB USER>
password = <PASSWORD>
dbname = <DB NAME>
dbname = vimbadmin
query = SELECT username FROM mailbox WHERE username='%s'
hosts = 127.0.0.1
mysql-virtual_forwardings.cf
user = <DB USER>
password = <PASSWORD>
dbname = <DB NAME>
query = SELECT goto FROM alias WHERE address='%s' and substring(address,1,1) <> '*'
hosts = 127.0.0.1
mysql-virtual_mailbox_domains.cf
user = <DB USER>
password = <PASSWORD>
dbname = <DB NAME>
query = SELECT domain as virtual FROM domain WHERE domain = '%s' AND backupmx = '0' AND active = '1'
hosts = 127.0.0.1
mysql-virtual_mailboxes.cf
user = <DB USER>
password = <PASSWORD>
dbname = <DB NAME>
hosts = 127.0.0.1
query = SELECT CONCAT(SUBSTRING_INDEX(username,'@',-1),'/',SUBSTRING_INDEX(username,'@',1),'/') FROM mailbox WHERE username='%s'
mysql-virtual_mailbox_limit_maps.cf
user = <DB USER>
password = <PASSWORD>
dbname = <DB NAME>
hosts = 127.0.0.1
query= SELECT quota FROM mailbox WHERE username='%s'
And:
main.cf
myhostname = <SERVER NAME>
mydestination = <SERVER NAME>, localhost, localhost.localdomain
mynetworks = 127.0.0.0/8
message_size_limit = 30720000
virtual_alias_domains =
virtual_alias_maps = proxy:mysql:/etc/postfix/mysql/mysql-virtual_domain_forwardings.cf,proxy:mysql:/etc/postfix/mysql/mysql-virtual_forwardings.cf, mysql:/etc/postfix/mysql/mysql-virtual_email2email.cf
virtual_mailbox_domains = proxy:mysql:/etc/postfix/mysql/mysql-virtual_mailbox_domains.cf
virtual_mailbox_maps = proxy:mysql:/etc/postfix/mysql/mysql-virtual_mailboxes.cf
virtual_mailbox_base = /mnt/mail
virtual_uid_maps = static:5000
virtual_gid_maps = static:5000
virtual_mailbox_limit_maps = proxy:mysql:/etc/postfix/mysql/mysql_virtual_mailbox_limit_maps.cf
smtpd_sasl_auth_enable = yes
broken_sasl_auth_clients = yes
smtpd_sasl_authenticated_header = yes
smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authentication,reject_unauth_destination,reject_invalid_hostname,
reject_unauth_pipelining,
reject_non_fqdn_sender,
reject_unknown_sender_domain,
reject_non_fqdn_recipient,
reject_unknown_recipient_domain,
reject_rhsbl_client blackhole.securitysage.com,
reject_rhsbl_sender blackhole.securitysage.com,
reject_rbl_client relays.ordb.org,
reject_rbl_client blackholes.easynet.nl,
reject_rbl_client cbl.abuseat.org,
reject_rbl_client proxies.blackholes.wirehub.net,
reject_rbl_client bl.spamcop.net,
reject_rbl_client sbl.spamhaus.org,
reject_rbl_client opm.blitzed.org,
reject_rbl_client dnsbl.njabl.org,
permit
smtpd_use_tls = yes
smtpd_tls_cert_file = /etc/postfix/smtpd.cert
smtpd_tls_key_file = /etc/postfix/smtpd.key
virtual_create_maildirsize = yes
virtual_maildir_extended = yes
proxy_read_maps = $local_recipient_maps $mydestination $virtual_alias_maps $virtual_alias_domains $virtual_mailbox_maps $virtual_mailbox_domains $relay_recipient_maps $relay_domains $canonical_maps $sender_canonical_maps $recipient_canonical_maps $relocated_maps $transport_maps $mynetworks $virtual_mailbox_limit_maps
virtual_transport = dovecot
dovecot_destination_recipient_limit = 1
readme_directory = /usr/share/doc/postfix
html_directory = /usr/share/doc/postfix/html
smtpd_helo_required = yes
content_filter = smtp-amavis:[127.0.0.1]:10024
#debug_peer_level = 2
#debug_peer_list = 127.0.0.1
inet_protocols = ipv4
virtual_mailbox_limit_override = yes
virtual_maildir_limit_message = "The user you are trying to reach is over quota."
virtual_overquota_bounce = yes