postfix +虚拟用户(db):添加donotreply地址

postfix +虚拟用户(db):添加donotreply地址

我在 Centos 6.5 上按照以下指南安装了 postfix/dovecot/mysql数字海洋

我的虚拟地址和别名工作正常,现在我正尝试添加 donotreply 别名。

在我的虚拟用户表中,我有一个[email protected]带有目的地的条目devnull

最后/etc/aliases

devnull: /dev/null

我追逐newaliases着它。

检查虚拟别名:

$ postmap -q [email protected] mysql:/etc/postfix/mysql-virtual-alias-maps.cf 
devnull

当我向此地址发送邮件时,收到“用户不存在”的退回邮件[email protected]

Mar 25 14:48:12 vps1 postfix/lmtp[7686]: 8543360392: to=<[email protected]>, orig_to=<[email protected]>, relay=host.mydomain.com[private/dovecot-lmtp], delay=0.14, delays=0.07/0.01/0.01/0.05, dsn=5.1.1, status=bounced (host host.mydomain.com[private/dovecot-lmtp] said: 550 5.1.1 <[email protected]> User doesn't exist: [email protected] (in reply to RCPT TO command))

每次更改后都会重新加载 Postfix(和 dovecot),但仍然没有运气。

我的 postfix 配置:

$ postconf -n
alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
command_directory = /usr/sbin
config_directory = /etc/postfix
daemon_directory = /usr/libexec/postfix
data_directory = /var/lib/postfix
debug_peer_level = 2
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
milter_default_action = accept
milter_protocol = 2
mydestination = localhost
myhostname = host.mydomain.com
myorigin = $mydomain
newaliases_path = /usr/bin/newaliases.postfix
non_smtpd_milters = $smtpd_milters
queue_directory = /var/spool/postfix
readme_directory = /usr/share/doc/postfix-2.6.6/README_FILES
sample_directory = /usr/share/doc/postfix-2.6.6/samples
sendmail_path = /usr/sbin/sendmail.postfix
setgid_group = postdrop
smtpd_milters = inet:127.0.0.1:8891
smtpd_recipient_restrictions = permit_sasl_authenticated, permit_mynetworks, reject_unauth_destination
smtpd_sasl_auth_enable = yes
smtpd_sasl_path = private/auth
smtpd_sasl_type = dovecot
smtpd_tls_auth_only = yes
smtpd_tls_cert_file = /path/to/ssl/cert
smtpd_tls_key_file = /path/to/ssl/privatekey
smtpd_use_tls = yes
unknown_local_recipient_reject_code = 550
virtual_alias_maps = mysql:/etc/postfix/mysql-virtual-alias-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_transport = lmtp:unix:private/dovecot-lmtp

我还尝试在 /etc/postfix/main.cf 中启用本地收件人映射

local_recipient_maps = unix:passwd.byname $alias_maps

但那也不起作用。

我还创建了一个 devnull 本地用户

$ useradd -M -d /dev/null -s /sbin/nologin devnull

但这也并没有改变什么。

如何获取虚拟别名以重定向到 /dev/null?

答案1

您也可以使用丢弃

放弃可选文本...

声明已成功投递并默默丢弃该消息。如果指定则记录可选文本,否则记录一般消息。

smtpd_recipient_restrictions =
 check_recipient_access hash:/etc/postfix/virtual_access
 reject_unknown_recipient_domain
 permit_mynetworks
 permit_sasl_authenticated
 reject_unauth_destination

# cat virtual_access
[email protected] DISCARD DEV-NULL

# postmap virtual_access

发送简单消息

# echo "Hello world" | swaks -4 --server localhost --from [email protected] --to [email protected] --h-Subject "Test message" --body -
=== Trying localhost:25...
=== Connected to localhost.
<-  220 smtp.example.net ESMTP Postfix
 -> EHLO jenkins.example.net
<-  250-smtp.example.net
<-  250-PIPELINING
<-  250-SIZE 10240000
<-  250-VRFY
<-  250-ETRN
<-  250-AUTH LOGIN PLAIN
<-  250-ENHANCEDSTATUSCODES
<-  250-8BITMIME
<-  250 DSN
 -> MAIL FROM:<[email protected]>
<-  250 2.1.0 Ok
 -> RCPT TO:<[email protected]>
<-  250 2.1.5 Ok
 -> DATA
<-  354 End data with <CR><LF>.<CR><LF>
 -> Date: Mon, 28 Mar 2016 09:09:50 +0000
 -> To: [email protected]
 -> From: [email protected]
 -> Subject: Test message
 -> X-Mailer: swaks v20130209.0 jetmore.org/john/code/swaks/
 ->
 -> Hello world
 ->
 ->
 -> .
<-  250 2.0.0 Ok: queued as 835721C7EBD
 -> QUIT
<-  221 2.0.0 Bye
=== Connection closed with remote host.

检查邮件日志

Mar 28 09:09:46 ci postfix/postfix-script[16971]: starting the Postfix mail system
Mar 28 09:09:46 ci postfix/master[16972]: daemon started -- version 2.6.6, configuration /etc/postfix
Mar 28 09:09:50 ci postfix/smtpd[16978]: connect from localhost[127.0.0.1]
Mar 28 09:09:50 ci postfix/smtpd[16978]: NOQUEUE: discard: RCPT from localhost[127.0.0.1]: <[email protected]>: Recipient address DEV-NULL; from=<[email protected]> to=<[email protected]> proto=ESMTP helo=<jenkins.example.net>
Mar 28 09:09:50 ci postfix/smtpd[16978]: 835721C7EBD: client=localhost[127.0.0.1]
Mar 28 09:09:50 ci postfix/smtpd[16978]: disconnect from localhost[127.0.0.1]

相关内容