我对服务器一无所知,设置 postfix 对我来说很困难。我知道这个错误很常见,但即使花了半天时间尝试了各种解决方案,也没有一个对我有用。有人能帮我一点吗?
我从 digitialocean (128.199.248.101) 购买了一个域名 (plainsight.in) 和一个服务器,并尝试设置它们以发送电子邮件。最终目标是设置 TLS 和整个shebang 并将电子邮件发送到 gmail.com,但目前甚至本地主机到本地主机的邮件都无法正常工作:
telnet localhost 25
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
220 dev.plainsight.in ESMTP Postfix (Ubuntu)
helo localhost
250 dev.plainsight.in
mail from: root@localhost
250 2.1.0 Ok
rcpt to: root@localhost
451 4.3.0 <root@localhost>: Temporary lookup failure
这让我很困惑。为什么 localhost 到 localhost 会导致查找失败?
至少所有邮件设置都是正确的,如 mxtoolbox 上所示页。此外,我的 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 (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
# 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 = dev.plainsight.in
#alias_maps = hash:/etc/aliases
virtual_alias_maps = hash:/etc/postfix/virtual
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = plainsight.in, personal-projects, localhost.localdomain, localhost
relayhost =
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128, 128.199.248.101
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
inet_protocols = all
邮件日志的最后几行是:
Dec 28 13:39:49 personal-projects postfix/trivial-rewrite[28844]: warning: hash:/etc/postfix/virtual is unavailable. open database /etc/postfix/virtual.db: No such file or directory
Dec 28 13:39:49 personal-projects postfix/trivial-rewrite[28844]: warning: hash:/etc/postfix/virtual: table lookup problem
Dec 28 13:39:53 personal-projects postfix/smtpd[28903]: warning: hash:/etc/postfix/virtual is unavailable. open database /etc/postfix/virtual.db: No such file or directory
Dec 28 13:39:53 personal-projects postfix/smtpd[28903]: warning: hash:/etc/postfix/virtual lookup error for "root@localhost"
Dec 28 13:39:53 personal-projects postfix/smtpd[28903]: NOQUEUE: reject: RCPT from localhost[127.0.0.1]: 451 4.3.0 <root@localhost>: Temporary lookup failure; from=<root@localhost> to=<root@localhost> proto=SMTP helo=<localhost>
Dec 28 13:39:56 personal-projects postfix/smtpd[28903]: disconnect from localhost[127.0.0.1]
请帮点忙好吗?:)
答案1
看起来你忘了运行postmap /etc/postfix/virtual
。请记住每次更改该文件时都执行此操作。