ใช้ Postfix แล้วส่งเมล์ไม่เข้า Maildir/ อะครับ

ลอง ping เครื่องตัวเองดูครับ

[root@host Maildir]# ping host.example.com
PING host.example.com (10.34.15.74) 56(84) bytes of data.
64 bytes from host.example.com (10.34.15.74): icmp_seq=1 ttl=64 time=0.035 ms

คือว่า Postfix รันอยู่ครับ

[root@host ~]# /etc/init.d/postfix status
master (pid 3862) is running...

ใช้ telnet ส่งเมล์ตามนี้ครับ

[root@host ~]# telnet localhost 25
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
220 host.example.com ESMTP Postfix
EHLO host.example.com
250-host.example.com
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
MAIL FROM: <root@host.example.com>
250 2.1.0 Ok
RCPT TO: <one@host.example.com>
250 2.1.5 Ok
DATA
354 End data with <CR><LF>.<CR><LF>
Subject: test
test
.
250 2.0.0 Ok: queued as B3292110039
QUIT
221 2.0.0 Bye
Connection closed by foreign host.

ใช้ ls -l ดูได้ตามนี้ครับ

[root@host /]# cd home/one/
[root@host one]# ls -l
total 80
drwx------ 5 one one 4096 2008-02-13 16:47 Maildir

[root@host one]# cd Maildir/
[root@host Maildir]# ls -l
total 24
drwx------ 2 one one 4096 2008-02-13 16:47 cur
drwx------ 2 one one 4096 2008-02-13 16:47 new
drwx------ 2 one one 4096 2008-02-13 16:47 tmp
[root@host Maildir]#

ใช้ tail ดู log ได้ตามนี้ครับ


[root@host Maildir]# tail -n 14 /var/log/maillog
Feb 14 23:16:33 host postfix/smtpd[29714]: connect from localhost.localdomain[127.0.0.1]
Feb 14 23:17:11 host postfix/smtpd[29714]: B3292110039: client=localhost.localdomain[127.0.0.1]
Feb 14 23:17:21 host postfix/cleanup[29718]: B3292110039: message-id=<20080214161711.B3292110039@host.example.com>
Feb 14 23:17:21 host postfix/qmgr[3865]: B3292110039: from=<root@host.example.com>, size=381, nrcpt=1 (queue active)
Feb 14 23:17:21 host postfix/local[29719]: warning: maildir access problem for UID/GID=500/500: create maildir file /home/one/Maildir/tmp/1203005841.P29719.host.example.com: Permission denied
Feb 14 23:17:21 host postfix/local[29719]: warning: perhaps you need to create the maildirs in advance
Feb 14 23:17:21 host postfix/local[29719]: B3292110039: to=<one@host.example.com>, relay=local, delay=31, delays=31/0.01/0/0.01, dsn=5.2.0, status=bounced (maildir delivery failed: create maildir file /home/one/Maildir/tmp/1203005841.P29719.host.example.com: Permission denied)
Feb 14 23:17:21 host postfix/cleanup[29718]: 923C511003B: message-id=<20080214161721.923C511003B@host.example.com>
Feb 14 23:17:21 host postfix/bounce[29720]: B3292110039: sender non-delivery notification: 923C511003B
Feb 14 23:17:21 host postfix/qmgr[3865]: 923C511003B: from=<>, size=2338, nrcpt=1 (queue active)
Feb 14 23:17:21 host postfix/qmgr[3865]: B3292110039: removed
Feb 14 23:17:21 host postfix/local[29719]: 923C511003B: to=<root@host.example.com>, relay=local, delay=0.01, delays=0/0/0/0, dsn=2.0.0, status=sent (delivered to maildir)
Feb 14 23:17:21 host postfix/qmgr[3865]: 923C511003B: removed
Feb 14 23:17:23 host postfix/smtpd[29714]: disconnect from localhost.localdomain[127.0.0.1]

อันนี้เป็น postconf -n ครับ


[root@host Maildir]# 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
debug_peer_level = 2
home_mailbox = Maildir/
html_directory = no
inet_interfaces = all
mail_owner = postfix
mailq_path = /usr/bin/mailq.postfix
manpage_directory = /usr/share/man
mydestination = $myhostname, localhost.$mydomain, localhost
mydomain = host.example.com
myhostname = host.example.com
mynetworks_style = host
myorigin = $myhostname
newaliases_path = /usr/bin/newaliases.postfix
queue_directory = /var/spool/postfix
readme_directory = /usr/share/doc/postfix-2.4.5/README_FILES
sample_directory = /usr/share/doc/postfix-2.4.5/samples
sendmail_path = /usr/sbin/sendmail.postfix
setgid_group = postdrop
unknown_local_recipient_reject_code = 550

ปัญหาเกิดแถวๆนี้ครับ

Feb 14 23:17:21 host postfix/local[29719]: warning: maildir access problem for UID/GID=500/500: create maildir file /home/one/Maildir/tmp/1203005841.P29719.host.example.com: Permission denied
Feb 14 23:17:21 host postfix/local[29719]: warning: perhaps you need to create the maildirs in advance

ลองหลายตำราแล้วยังไม่รอดครับ
รบกวนพี่ๆด้วยครับ ถ้าหลุดตรงนี้ไปผมจะลง Mailman ต่อแล้วครับ
ขอบคุณมากครับ

Postfix ทำงานอยู่ในกลุ่มใดครับ chown /home/one/Maildir ให้อยู่ในกลุ่มเดียวกัน

เข้าใจว่าอย่างนี้รึเปล่าครับ กลุ่ม 89 แล้วยังไงต่ออ่าครับ

[root@host ~]# id postfix
uid=89(postfix) gid=89(postfix) groups=89(postfix),12(mail) context=system_u:system_r:unconfined_t:s0-s0:c0.c1023

ลอง chown -R postfix:postfix /home/one/maildir/ แล้ว log แจ้งเป็น DEAD ครับ

[root@host Maildir]# tail -n 15 /var/log/maillog
Feb 15 01:18:57 host postfix/smtpd[30030]: disconnect from localhost.localdomain[127.0.0.1]
Feb 15 01:20:22 host postfix/smtpd[30030]: connect from localhost.localdomain[127.0.0.1]
Feb 15 01:20:46 host postfix/smtpd[30030]: DEAD7110039: client=localhost.localdomain[127.0.0.1]
Feb 15 01:20:53 host postfix/cleanup[30046]: DEAD7110039: message-id=<20080214182046.DEAD7110039@host.example.com>
Feb 15 01:20:53 host postfix/qmgr[3865]: DEAD7110039: from=<root@host.example.com>, size=381, nrcpt=1 (queue active)
Feb 15 01:20:53 host postfix/local[30049]: warning: maildir access problem for UID/GID=500/500: create maildir file /home/one/Maildir/tmp/1203013253.P30049.host.example.com: Permission denied
Feb 15 01:20:53 host postfix/local[30049]: warning: perhaps you need to create the maildirs in advance
Feb 15 01:20:53 host postfix/local[30049]: DEAD7110039: to=<one@host.example.com>, relay=local, delay=18, delays=18/0.01/0/0.01, dsn=5.2.0, status=bounced (maildir delivery failed: create maildir file /home/one/Maildir/tmp/1203013253.P30049.host.example.com: Permission denied)
Feb 15 01:20:53 host postfix/cleanup[30046]: CCB2D11003B: message-id=<20080214182053.CCB2D11003B@host.example.com>
Feb 15 01:20:53 host postfix/bounce[30050]: DEAD7110039: sender non-delivery notification: CCB2D11003B
Feb 15 01:20:53 host postfix/qmgr[3865]: CCB2D11003B: from=<>, size=2338, nrcpt=1 (queue active)
Feb 15 01:20:53 host postfix/qmgr[3865]: DEAD7110039: removed
Feb 15 01:20:53 host postfix/local[30049]: CCB2D11003B: to=<root@host.example.com>, relay=local, delay=0.01, delays=0/0/0/0, dsn=2.0.0, status=sent (delivered to maildir)
Feb 15 01:20:53 host postfix/qmgr[3865]: CCB2D11003B: removed
Feb 15 01:20:55 host postfix/smtpd[30030]: disconnect from localhost.localdomain[127.0.0.1]

แก้ chown กลับเป็นเหมือนเดิมอยู่ครับ

มี warning อันนึงว่า warning: perhaps you need to create the maildirs in advance

ตอนแรกแปลผิดว่าให้สร้าง Maildirs ในอนาคต
แต่จริงๆมันน่าจะแปลว่าให้สร้างอย่างพิเศษ …
ท่านใดพอมีคำสั่งให้ลองมั้ยอ่าครับ
รู้สึกผมจะใช้ root สร้างโดย mkdir เฉยๆอ่า …

ดูว่า postfix ทำงานในโหมด uid/gid อะไร
#ps aux|grep postfix
สมมติว่าเป็น user mail
ให้ chgrp ให้ตรงตามนั้น

#chown -R one:mail Maildir
#chmod -R 770 Maildir

ให้ได้ตามนี้ครับ
drwxrwx— 2 one mail 4096 2008-02-13 16:47 Maildir

drwxrwx— 2 one mail 4096 2008-02-13 16:47 cur
drwxrwx— 2 one mail 4096 2008-02-13 16:47 new
drwxrwx— 2 one mail 4096 2008-02-13 16:47 tmp

result ครับ

[root@host Maildir]# ps aux|grep postfix
root

ยังแก้ไม่ได้เลย ฮือๆ -_-

เปลี่ยนจาก mail เป็น postfix ครับ


postfix

ครับ

[root@host Maildir]# ls -la
total 40
drwxrwx---

พอเปลี่ยนกลับมาใช้ Postfix โดยแก้จาก Maildir/ เป็น Mailbox ปรากฏว่าส่งได้เหมือนกัน
แต่เล่นไปเล่นมา ส่งไม่ได้แล้วอ่าครับ เปิดปัญหากับ Maildir.lock

[root@host /]# tail -n 12 /var/log/maillog
Feb 15 09:29:48 host postfix/smtpd[774]: connect from localhost.localdomain[127.0.0.1]
Feb 15 09:30:30 host postfix/smtpd[774]: 14774110039: client=localhost.localdomain[127.0.0.1]
Feb 15 09:30:41 host postfix/cleanup[782]: 14774110039: message-id=<20080215013030.14774110039@host.example.com>
Feb 15 09:30:41 host postfix/qmgr[771]: 14774110039: from=<root@host.example.com>, size=379, nrcpt=1 (queue active)
Feb 15 09:30:41 host postfix/local[783]: 14774110039: to=<one@host.example.com>, relay=local, delay=24, delays=24/0.01/0/0.01, dsn=5.2.0, status=bounced (cannot update mailbox /home/one/Mailbox for user one. unable to create lock file /home/one/Mailbox.lock: Permission denied)
Feb 15 09:30:41 host postfix/cleanup[782]: C07FF11003C: message-id=<20080215013041.C07FF11003C@host.example.com>
Feb 15 09:30:41 host postfix/bounce[784]: 14774110039: sender non-delivery notification: C07FF11003C
Feb 15 09:30:41 host postfix/qmgr[771]: C07FF11003C: from=<>, size=2340, nrcpt=1 (queue active)
Feb 15 09:30:41 host postfix/qmgr[771]: 14774110039: removed
Feb 15 09:30:41 host postfix/local[783]: C07FF11003C: to=<root@host.example.com>, relay=local, delay=0.01, delays=0/0/0/0, dsn=2.0.0, status=sent (delivered to mailbox)
Feb 15 09:30:41 host postfix/qmgr[771]: C07FF11003C: removed
Feb 15 09:30:43 host postfix/smtpd[774]: disconnect from localhost.localdomain[127.0.0.1]

ลองสร้างไฟล์ Mailbox.lock ก็แล้ว

[root@host one]# ls -la
total 380
drwxrwx--- 28 one

จากที่หาทางแก้ดู Mailbox.lock น่าจะเป็นปัญหาจากการใช้ mode Mailbox อ่า
สรุป มีปัญหาทั้ง 2 mode ทั้ง Maildir/ และ Mailbox …

ตอนนี้ทิ้ง Postfix ใช้ sendmail และลง Mailman ใช้งานได้เรียบร้อยครับ …