我正在尝试为开发目的configurationpostfix,以便对网站上的电子邮件进行验收testing。 我已经完成了大部分的工作,但是只有一件事情我想正确设置,但不知道该怎么做。
目前,如果我的postfix服务器(在docker容器内)接收到一封邮件,它会向/var/mail/root邮箱/var/mail/root一条消息,通知/var/mail/root无法传递,如下所示:
$ cat /var/mail/root From MAILER-DAEMON Fri Sep 9 17:48:05 2016 Return-Path: <> X-Original-To: root@localhost Delivered-To: root@localhost Received: by localhost (Postfix) id 0209A1416E4; Fri, 9 Sep 2016 17:48:05 +0000 (UTC) Date: Fri, 9 Sep 2016 17:48:05 +0000 (UTC) From: MAILER-DAEMON@localhost (Mail Delivery System) Subject: Undelivered Mail Returned to Sender To: root@localhost Auto-Submitted: auto-replied MIME-Version: 1.0 Content-Type: multipart/report; report-type=delivery-status; boundary="0A7781416E0.1473443285/localhost" Message-Id: <20160909174805.0209A1416E4@localhost> This is a MIME-encapsulated message. --0A7781416E0.1473443285/localhost Content-Description: Notification Content-Type: text/plain; charset=us-ascii This is the mail system at host localhost. I'm sorry to have to inform you that your message could not be delivered to one or more recipients. It's attached below. For further assistance, please send mail to postmaster. If you do so, please include this problem report. You can delete your own text from the attached returned message. The mail system <[email protected]>: unknown user: "hello" --0A7781416E0.1473443285/localhost Content-Description: Delivery report Content-Type: message/delivery-status Reporting-MTA: dns; localhost X-Postfix-Queue-ID: 0A7781416E0 X-Postfix-Sender: rfc822; root@localhost Arrival-Date: Fri, 9 Sep 2016 17:48:03 +0000 (UTC) Final-Recipient: rfc822; [email protected] Original-Recipient: rfc822;[email protected] Action: failed Status: 5.1.1 Diagnostic-Code: X-Postfix; unknown user: "hello" --0A7781416E0.1473443285/localhost Content-Description: Undelivered Message Content-Type: message/rfc822 Return-Path: <root@localhost> Received: from localhost (unknown [172.20.0.6]) by localhost (Postfix) with ESMTP id 0A7781416E0 for <[email protected]>; Fri, 9 Sep 2016 17:48:03 +0000 (UTC) hhhhhhhhhhhhhhhhhhh --0A7781416E0.1473443285/localhost--
这就是我知道从网站发送的电子邮件。 对我来说,这几乎是正常的:我可以在testing中打开/var/mail/root ,阅读它的内容,确保有正确的主体,发件人和收件人。
不好的是,它不是一个交付给本地邮箱的邮件,而是一个关于邮件发送失败的通知,它恰好包含了邮件的内容。 我真正想要的是将我的后缀服务器收到的所有邮件保存到一个邮箱中,而不pipe收件人头中的用户名是什么。 这是我看到,当我的后缀服务器收到一封电子邮件:
Sep 9 18:42:01 db59bdabd3ea postfix/smtpd[1455]: connect from unknown[172.20.0.6] Sep 9 18:42:01 db59bdabd3ea postfix/smtpd[1455]: 7B8CF1416E0: client=unknown[172.20.0.6] Sep 9 18:42:03 db59bdabd3ea postfix/cleanup[1458]: 7B8CF1416E0: message-id=<> Sep 9 18:42:03 db59bdabd3ea postfix/qmgr[110]: 7B8CF1416E0: from=<root@localhost>, size=170, nrcpt=1 (queue active) Sep 9 18:42:03 db59bdabd3ea postfix/smtpd[1455]: disconnect from unknown[172.20.0.6] Sep 9 18:42:03 db59bdabd3ea postfix/local[1459]: 7B8CF1416E0: to=<[email protected]>, relay=local, delay=2.1, delays=2.1/0.01/0/0.02, dsn=5.1.1, status=bounced (unknown user: "ya") Sep 9 18:42:03 db59bdabd3ea postfix/cleanup[1458]: 908DE1416E4: message-id=<20160909184203.908DE1416E4@localhost> Sep 9 18:42:03 db59bdabd3ea postfix/bounce[1460]: 7B8CF1416E0: sender non-delivery notification: 908DE1416E4 Sep 9 18:42:03 db59bdabd3ea postfix/qmgr[110]: 908DE1416E4: from=<>, size=1824, nrcpt=1 (queue active) Sep 9 18:42:03 db59bdabd3ea postfix/qmgr[110]: 7B8CF1416E0: removed Sep 9 18:42:03 db59bdabd3ea postfix/local[1459]: 908DE1416E4: to=<root@localhost>, relay=local, delay=0.01, delays=0.01/0/0/0, dsn=2.0.0, status=sent (delivered to mailbox) Sep 9 18:42:03 db59bdabd3ea postfix/qmgr[110]: 908DE1416E4: removed
这里是我目前的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 (Debian/GNU) 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=no 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 = localhost alias_maps = hash:/etc/aliases alias_database = hash:/etc/aliases mydestination = pcre:/etc/postfix/mydestinations local_recipient_maps = mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 mailbox_size_limit = 0 recipient_delimiter = + inet_interfaces = all defer_transports = smtp #smtpd_sender_restrictions = static:HOLD relayhost = smtp_sasl_auth_enable = yes smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd smtp_sasl_security_options = smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt smtp_use_tls = yes smtp_tls_policy_maps = hash:/etc/postfix/tls_policy
我应该如何修改configuration以将所有收到的邮件发送到单个邮箱?
我将以下内容添加到我的configuration中:
always_bcc = root@localhost
现在postfix做我所需要的:它将所有收到的电子邮件保存在/var/mail/root ,而这些电子邮件没有任何额外的文本。