Всем добра.
Пытаюсь настроить postfix на использование виртуальных пользователей.
main.cf# See /usr/share/postfix/main.cf.dist for a commented, more complete version
# Debian specific: Specifying a file name will cause the first
# line of that file to be used as the name. The Debian default
# is /etc/mailname.
#myorigin = /etc/mailname
smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU)
biff = no
# appending .domain is the MUA's job.
append_dot_mydomain = no
# Uncomment the next line to generate "delayed mail" warnings
#delay_warning_time = 4h
readme_directory = no
# See http://www.postfix.org/COMPATIBILITY_README.html -- default to 2 on
# fresh installs.
compatibility_level = 2
# TLS parameters
smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
smtpd_use_tls=yes
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
# information on enabling SSL in the smtp client.
smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
myhostname = test.lan
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
#mydestination = $myhostname, test.lan, localhost
relayhost =
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
inet_protocols = all
relay_domains = mysql:/etc/postfix/mysql/relay_domains.cf
virtual_alias_maps = mysql:/etc/postfix/mysql/virtual_alias_maps.cf, mysql:/etc/postfix/mysql/virtual_alias_domain_maps.cf
virtual_mailbox_domains = mysql:/etc/postfix/mysql/virtual_mailbox_domains.cf
virtual_mailbox_maps = mysql:/etc/postfix/mysql/virtual_mailbox_maps.cf
# Директория для хранения почты
virtual_mailbox_base = /var/mail
virtual_minimum_uid = 1001
virtual_uid_maps = static:1001
virtual_gid_maps = static:1001
virtual_transport = dovecot
dovecot_destination_recipient_limit = 1
#контроль переписки
sender_bcc_maps = hash:/etc/postfix/sender_bcc_maps
recipient_bcc_maps = hash:/etc/postfix/recipient_bcc_maps
# Ограничение максимального размера письма в байтах
message_size_limit = 20000000
smtpd_soft_error_limit = 10
smtpd_hard_error_limit = 15
smtpd_error_sleep_time = 20
anvil_rate_time_unit = 60s
smtpd_client_connection_count_limit = 20
smtpd_client_connection_rate_limit = 30
smtpd_client_message_rate_limit = 30
smtpd_client_event_limit_exceptions = 127.0.0.0/8
smtpd_client_connection_limit_exceptions = 127.0.0.0/8
master.cfsmtp inet n - y - - smtpd
#smtp inet n - y - 1 postscreen
#smtpd pass - - y - - smtpd
#dnsblog unix - - y - 0 dnsblog
#tlsproxy unix - - y - 0 tlsproxy
#submission inet n - y - - smtpd
# -o syslog_name=postfix/submission
# -o smtpd_tls_security_level=encrypt
# -o smtpd_sasl_auth_enable=yes
# -o smtpd_tls_auth_only=yes
# -o smtpd_reject_unlisted_recipient=no
# -o smtpd_client_restrictions=$mua_client_restrictions
# -o smtpd_helo_restrictions=$mua_helo_restrictions
# -o smtpd_sender_restrictions=$mua_sender_restrictions
# -o smtpd_recipient_restrictions=
# -o smtpd_relay_restrictions=permit_sasl_authenticated,reject
# -o milter_macro_daemon_name=ORIGINATING
#smtps inet n - y - - smtpd
# -o syslog_name=postfix/smtps
# -o smtpd_tls_wrappermode=yes
# -o smtpd_sasl_auth_enable=yes
# -o smtpd_reject_unlisted_recipient=no
# -o smtpd_client_restrictions=$mua_client_restrictions
# -o smtpd_helo_restrictions=$mua_helo_restrictions
# -o smtpd_sender_restrictions=$mua_sender_restrictions
# -o smtpd_recipient_restrictions=
# -o smtpd_relay_restrictions=permit_sasl_authenticated,reject
# -o milter_macro_daemon_name=ORIGINATING
#628 inet n - y - - qmqpd
pickup unix n - y 60 1 pickup
cleanup unix n - y - 0 cleanup
qmgr unix n - n 300 1 qmgr
#qmgr unix n - n 300 1 oqmgr
tlsmgr unix - - y 1000? 1 tlsmgr
rewrite unix - - y - - trivial-rewrite
bounce unix - - y - 0 bounce
defer unix - - y - 0 bounce
trace unix - - y - 0 bounce
verify unix - - y - 1 verify
flush unix n - y 1000? 0 flush
proxymap unix - - n - - proxymap
proxywrite unix - - n - 1 proxymap
smtp unix - - y - - smtp
relay unix - - y - - smtp
-o syslog_name=postfix/$service_name
# -o smtp_helo_timeout=5 -o smtp_connect_timeout=5
showq unix n - y - - showq
error unix - - y - - error
retry unix - - y - - error
discard unix - - y - - discard
local unix - n n - - local
virtual unix - n n - - virtual
lmtp unix - - y - - lmtp
anvil unix - - y - 1 anvil
scache unix - - y - 1 scache
postlog unix-dgram n - n - 1 postlogd
#
# ====================================================================
# Interfaces to non-Postfix software. Be sure to examine the manual
# pages of the non-Postfix software to find out what options it wants.
#
# Many of the following services use the Postfix pipe(8) delivery
# agent. See the pipe(8) man page for information about ${recipient}
# and other message envelope options.
# ====================================================================
#
# maildrop. See the Postfix MAILDROP_README file for details.
# Also specify in main.cf: maildrop_destination_recipient_limit=1
#
maildrop unix - n n - - pipe
flags=DRhu user=vmail a#
uucp unix - n n - - pipe
flags=Fqhu user=uucp argv=uux -r -n -z -a$sender - $nexthop!rmail ($recipient)
#
# Other external delivery methods.
#
ifmail unix - n n - - pipe
flags=F user=ftn argv=/usr/lib/ifmail/ifmail -r $nexthop ($recipient)
bsmtp unix - n n - - pipe
flags=Fq. user=bsmtp argv=/usr/lib/bsmtp/bsmtp -t$nexthop -f$sender $recipient
scalemail-backend unix - n n - 2 pipe
flags=R user=scalemail argv=/usr/lib/scalemail/bin/scalemail-store ${nexthop} ${user} ${extension}
mailman unix - n n - - pipe
flags=FR user=list argv=/usr/lib/mailman/bin/postfix-to-mailman.py
${nexthop} ${user}
#указываем что доставкой занимается dovecot
dovecot unix - n n - - pipe
flags=DRhu user=vmail:vmail argv=/usr/libexec/dovecot/deliver -f ${sender} -d ${recipient}
rgv=/usr/bin/maildrop -d ${recipient}
файлы настроек для подключения к базе mysqlrelay_domains.cf
hosts = 127.0.0.1
user = postfix_for_mysql
password = Qwerty123
dbname = postfixadmin
query = SELECT domain FROM domain WHERE domain='%s' and backupmx = '1'
virtual_alias_domain_maps.cf
hosts = 127.0.0.1
user = postfix_for_mysql
password = Qwerty123
dbname = postfixadmin
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
virtual_alias_maps.cf
hosts = 127.0.0.1
user = postfix_for_mysql
password = Qwerty123
dbname = postfixadmin
query = SELECT goto FROM alias WHERE address='%s' AND active = '1'
virtual_mailbox_domains.cf
hosts = 127.0.0.1
user = postfix_for_mysql
password = Qwerty123
dbname = postfixadmin
query = SELECT domain FROM domain WHERE domain='%s' AND active = '1'
virtual_mailbox_maps.cf
hosts = 127.0.0.1
user = postfix_for_mysql
password = Qwerty123
dbname = postfixadmin
query = SELECT maildir FROM mailbox WHERE local_part='%u' AND active = '1'
В логах Jan 25 14:14:30 deb-srv postfix/smtpd[17004]: warning: hostname test does not resolve to address 192.168.4.1: Name or service not known
Jan 25 14:14:30 deb-srv postfix/smtpd[17004]: connect from unknown[192.168.4.1]
Jan 25 14:15:18 deb-srv postfix/trivial-rewrite[17006]: warning: do not list domain test.lan in BOTH mydestination and virtual_mailbox_domains
Jan 25 14:15:18 deb-srv postfix/smtpd[17004]: 029F58A02CA: client=unknown[192.168.4.1]
Jan 25 14:15:32 deb-srv postfix/cleanup[17007]: 029F58A02CA: message-id=<20200125071518.029F58A02CA@test.lan>
Jan 25 14:15:32 deb-srv postfix/qmgr[16866]: 029F58A02CA: from=<st@st.st>, size=286, nrcpt=2 (queue active)
Jan 25 14:15:32 deb-srv postfix/trivial-rewrite[17006]: warning: do not list domain test.lan in BOTH mydestination and virtual_mailbox_domains
Jan 25 14:15:32 deb-srv postfix/trivial-rewrite[17006]: warning: do not list domain test.lan in BOTH mydestination and virtual_mailbox_domains
Jan 25 14:15:32 deb-srv postfix/local[17008]: 029F58A02CA: to=<all_in@test.lan>, relay=local, delay=42, delays=42/0.01/0/0.01, dsn=5.1.1, status=bounced (unknown user: "all_in")
Jan 25 14:15:32 deb-srv postfix/local[17009]: 029F58A02CA: to=<test@test.lan>, relay=local, delay=42, delays=42/0.02/0/0, dsn=5.1.1, status=bounced (unknown user: "test")
Jan 25 14:15:32 deb-srv postfix/cleanup[17007]: 8DFE58A02CC: message-id=<20200125071532.8DFE58A02CC@test.lan>
Jan 25 14:15:32 deb-srv postfix/bounce[17010]: 029F58A02CA: sender non-delivery notification: 8DFE58A02CC
Jan 25 14:15:32 deb-srv postfix/qmgr[16866]: 8DFE58A02CC: from=<>, size=2027, nrcpt=1 (queue active)
Jan 25 14:15:32 deb-srv postfix/qmgr[16866]: 029F58A02CA: removed
Jan 25 14:15:33 deb-srv postfix/smtp[17013]: connect to aspmx.l.google.com[2a00:1450:4010:c05::1b]:25: Network is unreachable
Jan 25 14:15:34 deb-srv postfix/smtp[17013]: 8DFE58A02CC: to=<st@st.st>, relay=aspmx.l.google.com[64.233.162.27]:25, delay=2, delays=0/0.01/1.4/0.59, dsn=2.0.0, status=sent (250 2.0.0 OK 1579936534 c22si3306838ljk.319 - gsmtp)
Jan 25 14:15:34 deb-srv postfix/qmgr[16866]: 8DFE58A02CC: removed
Jan 25 14:15:35 deb-srv postfix/smtpd[17004]: disconnect from unknown[192.168.4.1] helo=1 mail=1 rcpt=1 data=1 quit=1 commands=5
проверяю через telnet
telnet test.lan 25
Trying 192.168.4.1...
Connected to test.lan.
Escape character is '^]'.
220 test.lan ESMTP Postfix (Debian/GNU)
helo qwe
250 test.lan
mail from:st@st.st
250 2.1.0 Ok
rcpt to:test@test.lan
250 2.1.5 Ok
data
354 End data with <CR><LF>.<CR><LF>
tema
str1
str2
.
250 2.0.0 Ok: queued as 029F58A02CA
quit
221 2.0.0 Bye
Connection closed by foreign host.
уже всю голову сломал почему в логах пишется что неивестный пользователь
базу создавал через postfixadmin
в базе вроде все пользователи на месте
select username, maildir, local_part from mailbox;
+------------------+-------------------+------------+
| username | maildir | local_part |
+------------------+-------------------+------------+
| all_in@test.lan | test.lan/all_in/ | all_in |
| all_out@test.lan | test.lan/all_out/ | all_out |
| test@test.lan | test.lan/test/ | test |
+------------------+-------------------+------------+
как можно проверить правильность настройки postfix?