3

I'm looking to know how servers mark emails as read and unread with IMAP or POP.

I've logged into my server (using cPanel) and navigated to my mail directory and downloaded the same email file, both read and unread, and used a file comparator on them, only to find both email files were identical.

If I move all my mail directory to a different server, how does it know which emails have been already read?


Update
One thing I notice from this two files is that the content is identical but there was a subtil change in the file name, the letter S was added at the end.

Unread: 1507345332.M378557P5...,S=78315,W=80152-2,c
Read:   1507345332.M378557P5...,S=78315,W=80152-2,Sc

Following the link provided by @rAlen I was able to see that the S stands for Seen and is added as soon as the email is read.

CIRCLE
  • 133
  • 7

1 Answers1

4

cPanel uses dovecot as POP3/IMAP server.

Messages that are read are moved from new to cur folder.

From: https://wiki2.dovecot.org/MailboxFormat/Maildir


Directory Structure

By default Dovecot uses Maildir++ directory layout for organizing mailbox directories. This means that all the folders are directly inside ~/Maildir directory:

  • ~/Maildir/new, ~/Maildir/cur and ~/Maildir/tmp directories contain the messages for INBOX. The tmp directory is used during delivery, new messages arrive in new and read shall be moved to cur by the clients.
  • ~/Maildir/.folder/ is a mailbox folder

  • ~/Maildir/.folder.subfolder/ is a subfolder of a folder (ie. "folder/subfolder")

You can also optionally use the "fs" layout by appending :LAYOUT=fs to mail_location. This makes the folder structure look like:

  • ~/Maildir/new, ~/Maildir/cur and ~/Maildir/tmp directories contain the messages for INBOX, just like with Maildir++.

  • ~/Maildir/folder/ is a mailbox folder

  • ~/Maildir/folder/subfolder/ is a subfolder of a folder


ralz
  • 2,691
  • 2
  • 17
  • 21
  • thank you @rAlen, initially I thought the same, that it would move emails around from different directories, but I currently have 3 unread emails in my inbox and my `~/Maildir/new` is empty – CIRCLE Oct 11 '17 at 14:14