我遇到了postfix无法将邮件发送到我的主目录的问题。 我有一个运行的Ubuntu 14.04服务器,由于encryption的家庭驱动器后缀的一些问题是无法访问我的Maildir。
在mail.log中,我得到了以下错误:
Apr 4 09:51:35 server postfix/smtpd[13658]: connect from localhost[127.0.0.1] Apr 4 09:51:35 server postfix/smtpd[13658]: 6FE354360A18: client=localhost[127.0.0.1] Apr 4 09:51:35 server postfix/cleanup[13661]: 6FE354360A18: message-id=<[email protected]> Apr 4 09:51:36 server postfix/smtpd[13658]: disconnect from localhost[127.0.0.1] Apr 4 09:51:36 server postfix/qmgr[2085]: 6FE354360A18: from=<[email protected]>, size=87170, nrcpt=1 (queue active) Apr 4 09:51:36 server postfix/local[13664]: warning: maildir access problem for UID/GID=1000/1000: create maildir file /home/user/Maildir/tmp/1459756296.P13664.server: Permission denied Apr 4 09:51:36 server postfix/local[13664]: warning: perhaps you need to create the maildirs in advance Apr 4 09:51:36 server postfix/local[13664]: 6FE354360A18: to=<andreas@localhost>, relay=local, delay=0.95, delays=0.88/0.01/0/0.06, dsn=5.2.0, status=bounced (maildir delivery failed: create maildir file /home/user/Maildir/tmp/1459756296.P13664.server: Permission denied) Apr 4 09:51:36 server postfix/cleanup[13661]: 668984360A1A: message-id=<20160404075136.668984360A1A@server> Apr 4 09:51:36 server postfix/bounce[13665]: 6FE354360A18: sender non-delivery notification: 668984360A1A Apr 4 09:51:36 server postfix/qmgr[2085]: 668984360A1A: from=<>, size=4544, nrcpt=1 (queue active) Apr 4 09:51:36 server postfix/qmgr[2085]: 6FE354360A18: removed Apr 4 09:51:36 server postfix/smtp[13666]: 668984360A1A: to=<[email protected]>, relay=smtp.otherserver.org:587, delay=0.54, delays=0.19/0.05/0.23/0.07, dsn=2.0.0, status=sent (250 2.0.0 Ok: queued as C979113D0138) Apr 4 09:51:36 server postfix/qmgr[2085]: 668984360A1A: removed
我重新启动服务器,并希望find同时在/ var / mail / xxx发送的电子邮件,但只有一个零字节的文件与我的用户名。
这是否意味着我收到的电子邮件丢失了? 我怎样才能configuration电子邮件保存?
编辑:mailq显示空的邮件队列。 EDIT2:增加了更多的日志输出
它应该在邮件队列中
发送简单的电子邮件
# echo "Hello world" | swaks -4 --server smtp.example.net --from [email protected] --to [email protected] --h-Subject "Test message" --body - === Trying smtp.example.net:25... === Connected to smtp.example.net. <- 220 smtp.example.net ESMTP Postfix -> EHLO tl-resin-node1.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: Tue, 05 Apr 2016 03:45:43 -0400 -> 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 581271C1811 -> QUIT <- 221 2.0.0 Bye === Connection closed with remote host.
检查smtp.example.net上的maillog
# cat /var/log/maillog | grep 581271C1811 Apr 5 07:45:41 ci postfix/smtpd[31639]: 581271C1811: client=smtp.example.com[192.168.88.130] Apr 5 07:45:41 ci postfix/cleanup[31642]: 581271C1811: message-id=<> Apr 5 07:45:41 ci postfix/qmgr[31633]: 581271C1811: from=<[email protected]>, size=389, nrcpt=1 (queue active) Apr 5 07:45:41 ci postfix/virtual[31643]: 581271C1811: to=<[email protected]>, relay=virtual, delay=0.07, delays=0.02/0.01/0/0.04, dsn=4.2.0, status=deferred (maildir delivery failed: create maildir file /var/mail/virtual/example.net/[email protected]/tmp/1459842341.P31643.ci.example.net: Permission denied)
检查maillog
# postqueue -p -Queue ID- --Size-- ----Arrival Time---- -Sender/Recipient------- 581271C1811 389 Tue Apr 5 07:45:41 [email protected] (maildir delivery failed: create maildir file /var/mail/virtual/example.net/[email protected]/tmp/1459842341.P31643.ci.example.net: Permission denied) [email protected] -- 1 Kbytes in 1 Request.
修复权限
# ls -la total 16 drwxr-xr-x 4 alex alex 4096 Mar 18 14:32 . drwxrwxr-x. 3 root mail 4096 Apr 2 03:35 .. drwx------ 3 virtual virtual 4096 Mar 15 09:18 example.com drwx------ 3 root virtual 4096 Mar 18 14:32 example.net # chown virtual:virtual example.net
冲洗邮件队列并再次检查maillog
# postqueue -f Apr 5 07:49:01 ci postfix/anvil[31640]: statistics: max cache size 1 at Apr 5 07:45:41 Apr 5 07:49:29 ci postfix/qmgr[31633]: 581271C1811: from=<[email protected]>, size=389, nrcpt=1 (queue active) Apr 5 07:49:29 ci postfix/virtual[31894]: 581271C1811: to=<[email protected]>, relay=virtual, delay=228, delays=228/0.02/0/0.06, dsn=2.0.0, status=sent (delivered to maildir) Apr 5 07:49:29 ci postfix/qmgr[31633]: 581271C1811: removed
TLDR:根据Postfix的默认行为,你的电子邮件被反弹(即你的发送者将得到未送达的消息),后缀将不会保持电子邮件,甚至在队列中。
根据汞和ALex_hha的日志,我可以得出结论, 虚拟守护进程 (ALex_hha case)或本地守护进程 (汞情况)提供邮件时会有不同的行为。 当虚拟守护程序由于权限问题而无法发送邮件时,它将使用延期邮件(软反弹),所以邮件停留在队列中。
Apr 5 07:45:41 ci postfix/virtual[31643]: 581271C1811: to=<[email protected]>, relay=virtual, delay=0.07, delays=0.02/0.01/0/0.04, dsn=4.2.0, status=deferred (maildir delivery failed: create maildir file /var/mail/virtual/example.net/[email protected]/tmp/1459842341.P31643.ci.example.net: Permission denied)
在另一种情况下,本地守护进程将弹回电子邮件(硬反弹),所以电子邮件不会留在队列中。
Apr 4 09:51:36 server postfix/local[13664]: 6FE354360A18: to=<andreas@localhost>, relay=local, delay=0.95, delays=0.88/0.01/0/0.06, dsn=5.2.0, status=bounced (maildir delivery failed: create maildir file /home/user/Maildir/tmp/1459756296.P13664.server: Permission denied)
当你查看virtual / maildir.c和local / maildir.c的源代码时,也可以查看这个行为,与dsb_simple函数一致。
本地/ maildir.c
dsb_simple(why, mbox_dsn(errno, "5.2.0"), "create maildir file %s: %m", tmpfile);
虚拟/ maildir.c
dsb_simple(why, mbox_dsn(errno, "4.2.0"), "create maildir file %s: %m", tmpfile);
基于上述源代码的AFAIK,这种行为是通过postfix main.cf不可configuration的。 但是尝试设置soft_bounce = yes ,但是在启用此function时请注意全局效果。