Начнем с начала. У меня есть два идентичных сервера VPS с ОС Ubuntu 18.04 и установленным на обоих Monit. Я настроил почтовый сервер в конфигурации монитора (для отправки предупреждений) как локальный хост на обоих. Проблема в том, что на одном сервере все работает нормально, а на другом я получаю сообщение об ошибке: NOQUEUE: reject: RCPT от localhost [127.0.0.1]: 550 5.1.1: Адрес получателя отклонен: Пользователь неизвестен в таблице виртуальных псевдонимов
Я не настраивал Dovecot и Postfix специально, поэтому он должен работать в обоих конфигурациях по умолчанию. Я сравнил конфигурацию рабочего постфиксного сервера и неработающую конфигурацию постфиксного сервера, и кажется, что они более или менее одинаковы. Они здесь:
Рабочий сервер:
# 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 (Ubuntu)
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 = sub.domain.com
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = $myhostname, sub.domain.com, localhost.domain.com, , 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
virtual_alias_maps = hash:/etc/postfix/virtual
sender_bcc_maps = hash:/etc/postfix/bcc
mailbox_command = /usr/bin/procmail-wrapper -o -a $DOMAIN -d $LOGNAME
home_mailbox = Maildir/
smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noanonymous
broken_sasl_auth_clients = yes
smtpd_recipient_restrictions = permit_mynetworks permit_sasl_authenticated reject_unauth_destination
smtp_tls_security_level = may
allow_percent_hack = no
и на этом сервере все работает нормально, без дополнительной настройки, просто поместив localhost в качестве почтового сервера в конфигурацию monit.
Не рабочий сервер:
# 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 (Ubuntu)
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/postfix/postfix.cert.pem
smtpd_tls_key_file = /etc/postfix/postfix.key.pem
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 = sub2.domain.com
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = $myhostname, sub2.domain.com, localhost.domain.com, ,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
virtual_alias_maps = hash:/etc/postfix/virtual
sender_bcc_maps = hash:/etc/postfix/bcc
mailbox_command = /usr/bin/procmail-wrapper -o -a $DOMAIN -d $LOGNAME
home_mailbox = Maildir/
smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noanonymous
broken_sasl_auth_clients = yes
smtpd_recipient_restrictions = permit_mynetworks permit_sasl_authenticated reject_unauth_destination
smtp_tls_security_level = dane
allow_percent_hack = no
smtpd_tls_CAfile = /etc/postfix/postfix.ca.pem
smtpd_tls_security_level = may
smtpd_tls_mandatory_protocols = !SSLv2, !SSLv3, !TLSv1, !TLSv1.1
Этот сервер генерирует вышеупомянутую ошибку.
Адрес назначения почты отличается от домена этих серверов, а почтовый ящик находится в Google. После проверки nslookup NX кажется, что все решено правильно:
Non-authoritative answer:
maildomain.com mail exchanger = 5 alt2.aspmx.l.google.com.
maildomain.com mail exchanger = 10 alt4.aspmx.l.google.com.
maildomain.com mail exchanger = 10 alt3.aspmx.l.google.com.
maildomain.com mail exchanger = 5 alt1.aspmx.l.google.com.
maildomain.com mail exchanger = 1 aspmx.l.google.com.
Еще одна вещь заключается в том, что на неработающем сервере есть apache с настроенным веб-сайтом maildomain.com, и я думаю, что, возможно, это запутывает сервер для отправки электронной почты. Возможно, он ищет только адрес электронной почты локально, а затем получает эту ошибку: RCPT от localhost [127.0.0.1]: 550 5.1.1: Адрес получателя отклонен: Пользователь неизвестен в таблице виртуальных псевдонимов
Любые идеи, как заставить его работать и что здесь может быть плохим, были бы идеальными. Заранее спасибо!
Боюсь, что пока не могу комментировать, так что это должен быть ответ ...
Похоже, что postfix не может найти пользователя в своей локальной базе данных, поэтому пользователь не выглядит локальным пользователем, а пользователь не находится в файле / etc / aliases. Или, и вы должны попробовать это. Вы не выполнили команду newaliases.
Для получения дополнительной помощи было бы полезно предоставить немного больше информации:
Получатель электронного письма
Содержимое соответствующих файлов / etc / aliases