在 maildir 中找不到 postfix/mailx 电子邮件,为什么?

在 maildir 中找不到 postfix/mailx 电子邮件,为什么?

CentOS 7开发机器上,我已配置 postfix 以允许在地址之间交换电子邮件localhostMailx还安装了。我可以发送电子邮件,日志文件表明邮件已送达。但是,我无法在终端中找到要查看的电子邮件。 我做错了什么?如何在终端中查看这些新发送的电子邮件?

我可以通过mailx root@localhost在终端中输入然后按照提示添加主题和正文,然后Ctrl-D获取命令提示符来发送电子邮件。此外,当我输入mail或以 root 身份登录时,终端会响应一些在更改为将电子邮件存储在mailx之前存储的旧电子邮件列表,但找不到新电子邮件。当我输入 时,我可以查看那些旧电子邮件,但当然新电子邮件不会存储在 中。postfix/Maildirnano /var/spool/mail/root/var/spool/mail/root

没有/var/log/mail。但是,nano /var/log/maillog包含:

Jan  5 12:09:40 localhost postfix/postfix-script[6162]: starting the Postfix mail system
Jan  5 12:09:40 localhost postfix/master[6164]: daemon started -- version 2.10.1, configuration /etc/postfix
Jan  5 12:46:00 localhost postfix/postfix-script[3036]: starting the Postfix mail system
Jan  5 12:46:00 localhost postfix/master[3047]: daemon started -- version 2.10.1, configuration /etc/postfix
Jan  5 13:12:02 localhost postfix/smtpd[4642]: connect from localhost.localdomain[127.0.0.1]
Jan  5 13:12:02 localhost postfix/smtpd[4642]: DB1249A618: client=localhost.localdomain[127.0.0.1]
Jan  5 13:12:02 localhost postfix/cleanup[4645]: DB1249A618: message-id=<1738078707.0.1420492322780.JavaMail.username@localhost.localdomain>
Jan  5 13:12:02 localhost postfix/qmgr[3058]: DB1249A618: from=<[email protected]>, size=632, nrcpt=1 (queue active)
Jan  5 13:12:02 localhost postfix/smtpd[4642]: disconnect from localhost.localdomain[127.0.0.1]
Jan  5 13:12:02 localhost postfix/local[4646]: DB1249A618: to=<[email protected]>, orig_to=<root@localhost>, relay=local, delay=0.11, delays=0.06/0.02/0/0.03, dsn=2.0.0, status=sent (delivered to maildir)
Jan  5 13:12:02 localhost postfix/qmgr[3058]: DB1249A618: removed
Jan  5 14:29:20 localhost postfix/pickup[5207]: 7F4439A616: uid=1000 from=<username>
Jan  5 14:29:20 localhost postfix/cleanup[5266]: 7F4439A616: message-id=<[email protected]>
Jan  5 14:29:20 localhost postfix/qmgr[3058]: 7F4439A616: from=<[email protected]>, size=334, nrcpt=1 (queue active)
Jan  5 14:29:20 localhost postfix/local[5271]: 7F4439A616: to=<[email protected]>, orig_to=<root@localhost>, relay=local, delay=0.13, delays=0.1/0.01/0/0.02, dsn=2.0.0, status=sent (delivered to maildir)
Jan  5 14:29:20 localhost postfix/qmgr[3058]: 7F4439A616: removed
Jan  5 14:57:10 localhost postfix/pickup[5207]: A21B49A618: uid=0 from=<root>
Jan  5 14:57:10 localhost postfix/cleanup[5529]: A21B49A618: message-id=<[email protected]>
Jan  5 14:57:10 localhost postfix/qmgr[3058]: A21B49A618: from=<[email protected]>, size=534, nrcpt=1 (queue active)
Jan  5 14:57:10 localhost postfix/local[5531]: A21B49A618: to=<[email protected]>, orig_to=<root>, relay=local, delay=0.38, delays=0.34/0.01/0/0.03, dsn=2.0.0, status=sent (delivered to maildir)
Jan  5 14:57:10 localhost postfix/qmgr[3058]: A21B49A618: removed
Jan  5 15:47:38 localhost postfix/pickup[5207]: F312D9A618: uid=0 from=<root>
Jan  5 15:47:39 localhost postfix/cleanup[5975]: F312D9A618: message-id=<[email protected]>
Jan  5 15:47:39 localhost postfix/qmgr[3058]: F312D9A618: from=<[email protected]>, size=458, nrcpt=1 (queue active)
Jan  5 15:47:39 localhost postfix/local[5977]: F312D9A618: to=<[email protected]>, orig_to=<username@localhost>, relay=local, delay=0.12, delays=0.09/0.01/0/0.03, dsn=2.0.0, status=sent (delivered to maildir)
Jan  5 15:47:39 localhost postfix/qmgr[3058]: F312D9A618: removed
Jan  5 15:48:20 localhost postfix/pickup[5207]: A826C9A618: uid=1000 from=<username>
Jan  5 15:48:20 localhost postfix/cleanup[5975]: A826C9A618: message-id=<[email protected]>
Jan  5 15:48:20 localhost postfix/qmgr[3058]: A826C9A618: from=<[email protected]>, size=461, nrcpt=1 (queue active)
Jan  5 15:48:20 localhost postfix/local[5977]: A826C9A618: to=<[email protected]>, orig_to=<username@localhost>, relay=local, delay=0.11, delays=0.08/0/0/0.03, dsn=2.0.0, status=sent (delivered to maildir)
Jan  5 15:48:20 localhost postfix/qmgr[3058]: A826C9A618: removed
Jan  5 15:48:29 localhost postfix/pickup[5207]: 54AA19A618: uid=1000 from=<username>
Jan  5 15:48:29 localhost postfix/cleanup[5975]: 54AA19A618: message-id=<[email protected]>
Jan  5 15:48:29 localhost postfix/qmgr[3058]: 54AA19A618: from=<[email protected]>, size=461, nrcpt=1 (queue active)
Jan  5 15:48:29 localhost postfix/local[5977]: 54AA19A618: to=<[email protected]>, orig_to=<root@localhost>, relay=local, delay=0.11, delays=0.09/0/0/0.02, dsn=2.0.0, status=sent (delivered to maildir)
Jan  5 15:48:29 localhost postfix/qmgr[3058]: 54AA19A618: removed
Jan  5 15:52:03 localhost postfix/pickup[5207]: C756E9A618: uid=0 from=<root>
Jan  5 15:52:03 localhost postfix/cleanup[6074]: C756E9A618: message-id=<[email protected]>
Jan  5 15:52:03 localhost postfix/qmgr[3058]: C756E9A618: from=<[email protected]>, size=491, nrcpt=1 (queue active)
Jan  5 15:52:03 localhost postfix/local[6076]: C756E9A618: to=<[email protected]>, orig_to=<root@localhost>, relay=local, delay=0.13, delays=0.09/0.01/0/0.03, dsn=2.0.0, status=sent (delivered to maildir)
Jan  5 15:52:03 localhost postfix/qmgr[3058]: C756E9A618: removed
Jan  5 16:02:36 localhost postfix/smtpd[6213]: connect from localhost.localdomain[127.0.0.1]
Jan  5 16:04:26 localhost postfix/smtpd[6213]: disconnect from localhost.localdomain[127.0.0.1]  

日志显示delivered to maildir。我是否使用了错误的语法来访问maildir内容?

另外,main.cf如下(注意,它需要允许本地主机帐户互相发送电子邮件):

queue_directory = /var/spool/postfix
command_directory = /usr/sbin
daemon_directory = /usr/libexec/postfix
data_directory = /var/lib/postfix
mail_owner = postfix
myorigin = localhost
inet_interfaces = localhost
inet_protocols = all
unknown_local_recipient_reject_code = 550
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
relayhost = 
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
home_mailbox = Maildir/
mailbox_command = 
debug_peer_level = 2
debugger_command =
    PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin
    ddd $daemon_directory/$process_name $process_id & sleep 5
sendmail_path = /usr/sbin/sendmail.postfix
newaliases_path = /usr/bin/newaliases.postfix
mailq_path = /usr/bin/mailq.postfix
setgid_group = postdrop
html_directory = no
manpage_directory = /usr/share/man
sample_directory = /usr/share/doc/postfix-2.10.1/samples
readme_directory = /usr/share/doc/postfix-2.10.1/README_FILES

我究竟做错了什么?

编辑:

根据masegaloeh的建议,我nano ~/.mailrc在保存之前输入并添加了以下内容:

set MAIL=/home/root/Maildir
set folder=mail

接下来,我输入了mailx,但终端响应了No mail for root。因此,我创建了一封新电子邮件,内容如下:

[root@localhost ~]# mailx
No mail for root
[root@localhost ~]# mailx root@localhost
Subject: another 905pm test.
gonna try again now.
EOT
[root@localhost ~]# mailx
No mail for root

如您所见,无法阅读我刚刚发送的电子邮件。我做错了什么?

答案1

默认情况下,mailx 将搜索已读 mbox 文件/var/spool/mail/$username。您可以使用以下命令查看它(归功于beginlinux.com 网站

$ set | grep -i mail
MAIL=/var/spool/mail/myuser
MAILCHECK=60

当您更改home_mailboxpostfix 中的参数时,您需要调整 mailx 配置,以便它在新位置搜索邮件。使用home_mailbox = Maildir/,postfix 会将电子邮件存储在 Maildir 目录中与用户主目录相对

摘自 Postfix人postconf

home_mailbox(默认:空)

相对于本地(8)用户主目录的邮箱文件的可选路径名。

为 qmail 样式的传递指定以“/”结尾的路径名。

因此,您的电子邮件将存储在 中$HOME/Maildir/,其中 $HOME 是您的主目录。对于 root,他的主目录是/root/;对于其他用户,他的主目录通常位于/home/otheruser/。请参阅穆鲁解释unix.SE: 根目录 /home 目录与 ~ (波浪符号)

对于你的情况,你需要编辑~/.mailrc并添加这两行

set MAIL=/root/Maildir
set folder=mail

参考文献 ->Fedora 论坛:~/.mailrc 更改

答案2

我遇到了同样的问题,所有电子邮件都发送到[电子邮件保护]未被保存到 root 邮箱

我在 mail.cf home_mailbox = Maildir/ 中注释掉了此行

然后我必须将 var/spool/mail/root 的所有者设置为“root”

如果您有其他用户,那么您可能必须在 var/spool/mail/ 文件夹中使用他们的用户名创建一个文件,并将文件所有者设置为相同的用户名?

相关内容