我想为我的域名设置一个接收所有邮件的电子邮件地址。例如(任何发送到[电子邮件保护]或者[电子邮件保护]将转到特定邮箱)。我已让 Postfix 处理本地邮件,但它拒绝来自机器主机名之外的电子邮件。
我按照此配置将所有收到的邮件发送到特定帐户:http://www.cyberciti.biz/faq/howto-setup-postfix-catch-all-email-accounts/。当我在同一台机器上发送电子邮件时,它可以按预期工作:
paul@server1:~/Maildir/new$ ls -l ~/Maildir/new/
total 0
paul@server1:~/Maildir/new$ echo "test email" | mail -s "test subject" [email protected]
paul@server1:~/Maildir/new$ ls -l ~/Maildir/new/
total 4
-rw------- 1 paul paul 2112 Jun 15 19:39 1339774754.V90ceIf21c25M531738.server1
paul@server1:~/Maildir/new$
但是当我尝试从另一个域发送(我将使用 Gmail 作为示例)时,我收到了未送达通知。
这是 Gmail 和本地通话的 mail.log:
Jun 15 19:38:40 server1 postfix/pickup[489]: 88ADDF21C35: uid=1000 from=<paul>
Jun 15 19:38:40 server1 postfix/cleanup[1909]: 88ADDF21C35: message-id=<[email protected]>
Jun 15 19:38:40 server1 postfix/qmgr[490]: 88ADDF21C35: from=<[email protected]>, size=349, nrcpt=1 (queue active)
Jun 15 19:38:40 server1 postfix/local[1911]: 88ADDF21C35: to=<[email protected]>, relay=local, delay=0.08, delays=0.05/0.01/0/0.02, dsn=5.1.1, status=bounced (unknown user: "u123456")
Jun 15 19:38:40 server1 postfix/cleanup[1909]: 93FDAF21C39: message-id=<[email protected]>
Jun 15 19:38:40 server1 postfix/bounce[1912]: 88ADDF21C35: sender non-delivery notification: 93FDAF21C39
Jun 15 19:38:40 server1 postfix/qmgr[490]: 93FDAF21C39: from=<>, size=2096, nrcpt=1 (queue active)
Jun 15 19:38:40 server1 postfix/qmgr[490]: 88ADDF21C35: removed
Jun 15 19:38:40 server1 postfix/local[1911]: 93FDAF21C39: to=<[email protected]>, relay=local, delay=0.02, delays=0.01/0/0/0, dsn=2.0.0, status=sent (delivered to maildir)
Jun 15 19:38:40 server1 postfix/qmgr[490]: 93FDAF21C39: removed
Jun 15 19:39:14 server1 postfix/pickup[489]: 7B866F21C35: uid=1000 from=<paul>
Jun 15 19:39:14 server1 postfix/cleanup[1909]: 7B866F21C35: message-id=<[email protected]>
Jun 15 19:39:14 server1 postfix/qmgr[490]: 7B866F21C35: from=<[email protected]>, size=349, nrcpt=1 (queue active)
Jun 15 19:39:14 server1 postfix/local[1911]: 7B866F21C35: to=<[email protected]>, relay=local, delay=0.02, delays=0.01/0/0/0, dsn=5.1.1, status=bounced (unknown user: "u123456")
Jun 15 19:39:14 server1 postfix/cleanup[1909]: 7EFA0F21C39: message-id=<[email protected]>
Jun 15 19:39:14 server1 postfix/qmgr[490]: 7EFA0F21C39: from=<>, size=2096, nrcpt=1 (queue active)
Jun 15 19:39:14 server1 postfix/bounce[1912]: 7B866F21C35: sender non-delivery notification: 7EFA0F21C39
Jun 15 19:39:14 server1 postfix/qmgr[490]: 7B866F21C35: removed
Jun 15 19:39:14 server1 postfix/local[1911]: 7EFA0F21C39: to=<[email protected]>, relay=local, delay=0.02, delays=0.01/0/0/0, dsn=2.0.0, status=sent (delivered to maildir)
Jun 15 19:39:14 server1 postfix/qmgr[490]: 7EFA0F21C39: removed
Jun 15 19:40:02 server1 postfix/pickup[489]: 6EC93F21C39: uid=107 from=<smmsp>
Jun 15 19:40:02 server1 postfix/cleanup[1909]: 6EC93F21C39: message-id=<[email protected]>
Jun 15 19:40:02 server1 postfix/qmgr[490]: 6EC93F21C39: from=<[email protected]>, size=665, nrcpt=1 (queue active)
Jun 15 19:40:02 server1 postfix/local[1911]: 6EC93F21C39: to=<[email protected]>, orig_to=<root>, relay=local, delay=0.11, delays=0.1/0/0/0, dsn=2.0.0, status=sent (delivered to maildir)
Jun 15 19:40:02 server1 postfix/qmgr[490]: 6EC93F21C39: removed
Jun 15 19:40:53 server1 postfix/smtpd[1975]: connect from mail-wg0-f42.google.com[74.125.82.42]
Jun 15 19:40:53 server1 postfix/smtpd[1975]: NOQUEUE: reject: RCPT from mail-wg0-f42.google.com[74.125.82.42]: 550 5.1.1 <[email protected]>: Recipient address rejected: User unknown in local recipient table; from=<[email protected]> to=<[email protected]> proto=ESMTP helo=<mail-wg0-f42.google.com>
Jun 15 19:40:54 server1 postfix/smtpd[1975]: disconnect from mail-wg0-f42.google.com[74.125.82.42]
与本地发送不同,目录中没有新电子邮件。
paul@server1:~/Maildir/new$ ls -l
total 4
-rw------- 1 paul paul 2112 Jun 15 19:39 1339774754.V90ceIf21c25M531738.server1
paul@server1:~/Maildir/new$
非本地邮件是否会导致这种情况?如何让 postfix 接受所有用户的所有邮件并将其放入特定用户的收件箱?
编辑:添加 main.cf
paul@server1:~/Maildir/new$ cat /etc/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 (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.
myhostname = server1.helpmeco.de
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = helpmeco.de, server1.helpmeco.de, localhost.helpmeco.de, localhost
relayhost =
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_command =
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
home_mailbox = Maildir/
答案1
搞清楚了。我的 main.cf 文件中缺少一些条目:
smtpd_recipient_restrictions = permit_mynetworks, permit_auth_destination, reject
virtual_alias_maps = hash:/etc/postfix/virtual
local_recipient_maps =
制作完整的 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
smtpd_reject_unlisted_recipient = no
smtpd_recipient_restrictions = permit_mynetworks, permit_auth_destination, reject
# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
# information on enabling SSL in the smtp client.
myhostname = server1.helpmeco.de
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = helpmeco.de, server1.helpmeco.de, localhost.helpmeco.de, localhost
relayhost =
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_command =
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
home_mailbox = Maildir/
virtual_alias_maps = hash:/etc/postfix/virtual
local_recipient_maps =