Dovecot – Fix Mail Not Fetching from /var/spool/mail/$user to mail_location

dovecotmailboxsendmail

As seen in the /var/log/maillog when mail received or sent, sendmail saving mails to /var/spool/mail/$user and logging them as stat=Sent

When a user try to send or receive mail via imap it is not shown in ~$user/mail/

/etc/dovecot/conf.d/10-mail.conf

mail_location = maildir:~/mail:INBOX=~/mail/.INBOX


Directory and file permissons are correct.

[root@mail ~]# ll -d /home/$user/mail
drwx------. 7 $user $user 4096 Oct 25 14:04 /home/$user/mail

There is no log about this problem in /var/log/maillog. I am wondering that how to send mail file to user's mail directory?

Best Answer

Andrzej's comment above is right on; dovecot isn't supposed to automagically do that. You will either need to tell sendmail to put the mail where dovecot is expecting it (or at least tell its local delivery agent to do that), or tell dovecot to expect it where sendmail puts it.

In my case, I do the latter; my dovecot.conf includes the line

mail_location = mbox:~/:INBOX=/var/spool/mail/%u

Edit: your sendmail is configured much as mine, using procmail as the local MDA. The man page for procmail suggests that /var/spool/mail/$user is the default place that procmail wil put incoming mail, if no other is provided:

   /var/spool/mail/$LOGNAME
                          system mailbox; both the system mailbox and the immediate directory it is in will be created  every
                          time procmail starts and either one is not present

so I repeat my point: you can either configure sendmail's MDA, procmail, to put incoming mail in /home/$user/mail/.INBOX, or you can configure dovecot to look in /var/spool/mail/$user. But you will have to do one of these things, it's not going to happen by magic.