Postfix 不尊重 mysql 别名域

Postfix 不尊重 mysql 别名域

因此,设置使用 postfix、dovecot、postfixadmin 和 mysql。我已将 postfix admin 配置为将一个域“name.co.uk”别名为“name.net”,我在数据库中看到了这一点,因此这里没有问题。但是,当向“name.co.uk”发送邮件时,它不会发送到“name.net”,我可以从它没有出现在邮箱中,而是放在旧域的虚拟邮件目录中(这本来就不应该存在!)这一事实中看出这一点。通过日志文件跟踪它,它似乎根本没有考虑别名。

#~ postconf -n
alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
broken_sasl_auth_clients = yes
command_directory = /usr/sbin
config_directory = /etc/postfix
daemon_directory = /usr/libexec/postfix
data_directory = /var/lib/postfix
debug_peer_level = 2
debugger_command = PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin ddd $daemon_directory/$process_name $process_id & sleep 5
dovecot_destination_recipient_limit = 1
home_mailbox = Maildir/
html_directory = no
inet_interfaces = all
inet_protocols = all
mail_owner = postfix
mailq_path = /usr/bin/mailq.postfix
manpage_directory = /usr/share/man
message_size_limit = 30720000
mydestination = localhost, localhost.localdomain
myhostname = company.net
mynetworks = 127.0.0.0/8
newaliases_path = /usr/bin/newaliases.postfix
policyd-spf_time_limit = 3600
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
queue_directory = /var/spool/postfix
readme_directory = /usr/share/doc/postfix-2.10.1/README_FILES
sample_directory = /usr/share/doc/postfix-2.10.1/samples
sendmail_path = /usr/sbin/sendmail.postfix
setgid_group = postdrop
smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination, check_policy_service unix:private/policyd-spf
smtpd_sasl_auth_enable = yes
smtpd_sasl_authenticated_header = yes
smtpd_sasl_path = private/auth
smtpd_sasl_type = dovecot
smtpd_tls_CAfile = /etc/letsencrypt/live/mail.company.net/cert.pem
smtpd_tls_cert_file = /etc/letsencrypt/live/mail.company.net/fullchain.pem
smtpd_tls_key_file = /etc/letsencrypt/live/mail.company.net/privkey.pem
smtpd_tls_loglevel = 3
smtpd_tls_received_header = yes
smtpd_tls_session_cache_timeout = 3600s
smtpd_use_tls = yes
tls_random_source = dev:/dev/urandom
unknown_local_recipient_reject_code = 550
virtual_alias_domains = mysql:/etc/postfix/mysql_virtual_alias_domains_catchall_maps.cf, mysql:/etc/postfix/mysql_virtual_alias_domains_mailbox_maps.cf, mysql/etc/postfix/mysql_virtual_alias_domains_maps.cf
virtual_alias_maps = mysql:/etc/postfix/mysql_virtual_alias_maps.cf
virtual_gid_maps = static:5000
virtual_mailbox_base = /home/vmail
virtual_mailbox_domains = mysql:/etc/postfix/mysql_virtual_domains_maps.cf
virtual_mailbox_limit = 51200000
virtual_mailbox_maps = mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf, mysql:/etc/postfix/mysql_virtual_mailbox_limit_maps.cf
virtual_minimum_uid = 5000
virtual_transport = dovecot
virtual_uid_maps = static:5000

然后在配置文件中

#~ for name in /etc/postfix/mysql_virtual_*; do echo $name && cat $name; done
/etc/postfix/mysql_virtual_alias_domains_catchall_maps.cf
user = mail_admin
password = password
hosts = localhost
dbname = mail
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 AND alias_domain.active='1'
/etc/postfix/mysql_virtual_alias_domains_mailbox_maps.cf
user = mail_admin
password = password
hosts = localhost
dbname = mail
query = SELECT maildir FROM mailbox,alias_domain WHERE alias_domain.alias_domain = '%d' and mailbox.username = CONCAT('%u', '@', alias_domain.target_domain) AND mailbox.active = 1 AND alias_domain.active='1'
/etc/postfix/mysql_virtual_alias_domains_maps.cf
user = mail_admin
password = password
hosts = localhost
dbname = mail
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 AND alias_domain.active='1'
/etc/postfix/mysql_virtual_alias_maps.cf
user = mail_admin
password = password
hosts = localhost
dbname = mail
table = alias
select_field = goto
where_field = address
/etc/postfix/mysql_virtual_domains_maps.cf
user = mail_admin
password = password
hosts = localhost
dbname = mail
table = domain
select_field = domain
where_field = domain
#additional_conditions = and backupmx = '0' and active = '1'
/etc/postfix/mysql_virtual_mailbox_limit_maps.cf
user = mail_admin
password = password
hosts = localhost
dbname = mail
table = mailbox
select_field = quota
where_field = username
#additional_conditions = and active = '1'
/etc/postfix/mysql_virtual_mailbox_maps.cf
user = mail_admin
password = password
hosts = localhost
dbname = mail
table = mailbox
select_field = maildir
where_field = username
#additional_conditions = and active = '1'

答案1

问题已解决。缺少:proxy之前的内容:mysql

新的配置文件

alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
broken_sasl_auth_clients = yes
command_directory = /usr/sbin
config_directory = /etc/postfix
daemon_directory = /usr/libexec/postfix
data_directory = /var/lib/postfix
debug_peer_level = 2
debugger_command = PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin ddd $daemon_directory/$process_name $process_id & sleep 5
dovecot_destination_recipient_limit = 1
home_mailbox = Maildir/
html_directory = no
inet_interfaces = all
inet_protocols = all
mail_owner = postfix
mailq_path = /usr/bin/mailq.postfix
manpage_directory = /usr/share/man
message_size_limit = 30720000
mydestination = localhost, localhost.localdomain
myhostname = company.net
mynetworks = 127.0.0.0/8
newaliases_path = /usr/bin/newaliases.postfix
policyd-spf_time_limit = 3600
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
queue_directory = /var/spool/postfix
readme_directory = /usr/share/doc/postfix-2.10.1/README_FILES
sample_directory = /usr/share/doc/postfix-2.10.1/samples
sendmail_path = /usr/sbin/sendmail.postfix
setgid_group = postdrop
smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination, check_policy_service unix:private/policyd-spf
smtpd_sasl_auth_enable = yes
smtpd_sasl_authenticated_header = yes
smtpd_sasl_path = private/auth
smtpd_sasl_type = dovecot
smtpd_tls_CAfile = /etc/letsencrypt/live/mail.company.net/cert.pem
smtpd_tls_cert_file = /etc/letsencrypt/live/mail.company.net/fullchain.pem
smtpd_tls_key_file = /etc/letsencrypt/live/mail.company.net/privkey.pem
smtpd_tls_loglevel = 3
smtpd_tls_received_header = yes
smtpd_tls_session_cache_timeout = 3600s
smtpd_use_tls = yes
tls_random_source = dev:/dev/urandom
unknown_local_recipient_reject_code = 550
virtual_alias_maps = proxy:mysql:/etc/postfix/sql/mysql_virtual_alias_maps.cf, proxy:mysql:/etc/postfix/sql/mysql_virtual_alias_domain_maps.cf, proxy:mysql:/etc/postfix/sql/mysql_virtual_alias_domain_catchall_maps.cf
virtual_gid_maps = static:5000
virtual_mailbox_base = /home/vmail
virtual_mailbox_domains = proxy:mysql:/etc/postfix/sql/mysql_virtual_domains_maps.cf
virtual_mailbox_limit = 51200000
virtual_mailbox_maps = proxy:mysql:/etc/postfix/sql/mysql_virtual_mailbox_maps.cf, proxy:mysql:/etc/postfix/sql/mysql_virtual_alias_domain_mailbox_maps.cf
virtual_minimum_uid = 5000
virtual_transport = dovecot
virtual_uid_maps = static:5000

/etc/postfix/sql/mysql_virtual_alias_domain_catchall_maps.cf
# mysql_virtual_alias_domain_catchall_maps.cf
# handles catch-all settings of target-domain
user = mail_admin
password = password
hosts = localhost
dbname = mail
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 AND alias_domain.active='1'

/etc/postfix/sql/mysql_virtual_alias_domain_mailbox_maps.cf
# mysql_virtual_alias_domain_mailbox_maps.cf
user = mail_admin
password = password
hosts = localhost
dbname = mail
query = SELECT maildir FROM mailbox,alias_domain WHERE alias_domain.alias_domain = '%d' and mailbox.username = CONCAT('%u', '@', alias_domain.target_domain) AND mailbox.active = 1 AND alias_domain.active='1'

/etc/postfix/sql/mysql_virtual_alias_domain_maps.cf
# mysql_virtual_alias_domain_maps.cf
user = mail_admin
password = password
hosts = localhost
dbname = mail
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 AND alias_domain.active='1'

/etc/postfix/sql/mysql_virtual_alias_maps.cf
# mysql_virtual_alias_maps.cf
user = mail_admin
password = password
hosts = localhost
dbname = mail
query = SELECT goto FROM alias WHERE address='%s' AND active = '1'
#expansion_limit = 100

/etc/postfix/sql/mysql_virtual_domains_maps.cf
# mysql_virtual_domains_maps.cf
user = mail_admin
password = password
hosts = localhost
dbname = mail
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

/etc/postfix/sql/mysql_virtual_mailbox_limit_maps.cf
# mysql_virtual_mailbox_limit_maps.cf
user = mail_admin
password = password
hosts = localhost
dbname = mail
query = SELECT quota FROM mailbox WHERE username='%s' AND active = '1'

/etc/postfix/sql/mysql_virtual_mailbox_maps.cf
# mysql_virtual_mailbox_maps.cf
user = mail_admin
password = password
hosts = localhost
dbname = mail
query           = SELECT maildir FROM mailbox WHERE username='%s' AND active = '1'
#expansion_limit = 100

相关内容