IMAP server can't read (open) mails using fetchmail, procmail & dovecot
Your combination of software is a bit unusual these days (i.e. pretty standard 10-20 years ago). I'm guessing what you are doing is using fetchmail to connect to a POP server, and then it passes the mail to procmail to deliver the mail into local directories. This approach has become unusual in part because there's not many servers now that support POP only, and IMAP allows better options for moving mail between servers after delivery. If there's an option to use IMAP on the upstream server, then take a look at imapfilter. It's also unusual these days to want to run a mail server that can't accept direct delivery, which would allow you to just set up a mail forwarding rule on the upstream server.
You are presumably running into problems because you are using procmail to deliver directly into local directories, and doing so with the procmail process running as root, which is not what dovecot runs as, so dovecot can't read the files.
You could figure out how to run procmail as the correct user, or (if run as root) how to tell it to store files with the correct ownership. You might get a degree of compatibility, but for instance dovecot won't get to index the emails properly as they arrive, so search will be impaired.
I suggest that you use dovecot's deliver
as a local delivery agent. It might replace procmail, or it might be called by procmail 1,2 . In either case you'll need to call it with appropriate an argument (-d
), identifying the user you are delivering to. If you are using procmail to make decisions about which mail folder to deliver to, you might want to use the -p
argument for that, or you might be better off using dovecot's sieve filtering engine to make those decisions. procmail is really at its best when dealing with system users rather than virtual users.
Sieve is a better designed solution than procmail for virtual users, though it's an open question which has a less pleasant filter syntax. I had many years of good service from procmail, and I currently use a bit of sieve because it acts before delivery, but for transferring mail between servers after delivery, and where circumstances allow, I'd much prefer writing filters with imapfilter
.