postfix +虚拟用户(db):添加一个不可回收的地址

在DigitalOcean的指南中,我在Centos 6.5上安装了postfix / dovecot / mysql。

我有虚拟地址和别名工作得很好,现在我试图添加一个donotreply别名。

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

/etc/aliases我有

 devnull: /dev/null 

在这之后我跑了新的。

检查虚拟别名:

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

当我发送邮件到这个地址,我得到一个“用户不存在”popup[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)在每次更改后都被重新加载,但仍然没有运气。

我的后缀conf:

 $ 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 

但是这也不起作用。

我也创build了一个devnull本地用户

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

但这也没有改变。

我如何获得虚拟别名redirect到/ dev / null?

你也可以使用DISCARD

DISCARD可选文字…

声称成功交付,并默默丢弃消息。 logging可选文本(如果指定),否则logging通用消息。

 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. 

检查maillog

 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]