37

I can't find any documentation on how postfix stores email. Where is it stored, and in what format? I'm using Ubuntu server 11

Michael Mrozek
  • 91,316
  • 38
  • 238
  • 232
lovespring
  • 823
  • 2
  • 10
  • 14

2 Answers2

41

Probably /var/mail/[username] or the more traditional /var/spool/mail/[username]

The normal format, called "mbox", uses a line that starts with "From " to indicate the start of each message - this is one reason why many email clients will change "From " in the body of the message to ">From ". You can also configure it to use "maildir", in which /var/mail/[username] is a directory in which every email message is a file in that directory.

Paul Tomblin
  • 1,648
  • 1
  • 13
  • 16
  • 1
    This is of course assuming that the user doesn't have `procmail` configured to do it for him instead. – Shadur Oct 26 '11 at 05:13
  • It's also assuming that they haven't installed cyrus-sasl which moves things around. We're trying to keep things simple. – Paul Tomblin Oct 26 '11 at 13:00
  • I've installed postfix, both of the above paths are empty, but I can see the emails in the squirrel web interface. – Alex Jun 30 '18 at 04:21
  • 2
    @Alex Look in `/etc/postfix/main.cf` for the `mail_spool_directory` and `home_mailbox` and see which one is uncommented.Also look to see if `mailbox_transport = cyrus` is uncommented. Like I said above, cyrus does complicated things with your mail. – Paul Tomblin Jul 01 '18 at 03:08
16

For outbound mail (you didn't specify, and inbound is answered elsewhere) it is in /var/spool/postfix. If you look there you will find all sorts of subdirectories.

Aaron D. Marasco
  • 5,708
  • 24
  • 29
  • I cannot find my outbound mails inthere on my debian machine. – simonpie May 06 '13 at 00:45
  • 1
    I cannot find my outbound mails in there on my debian machine. This directory is used but things there are store only trensiently. Alpine stores outbound emails in `/home/[username]/mail/sent-mail` for example. – simonpie May 06 '13 at 00:57
  • 2
    Postfix does not store outgoing mail permanently. Once it's off the system, it's no longer the responsibility of the MTA. If you need a permanent copy, Bcc: yourself, or use whatever your MUA offers (like you mention for Alpine). – tripleee Jun 11 '14 at 09:09
  • Yes, it's ephemeral. Take down your net connection and send an email. Then you'll see something queued up... – Aaron D. Marasco Feb 02 '15 at 01:20
  • The files are not directly useful, though. Messages which could not be delivered are in `/var/spool/postfix/deferred` but the files are in some internal format. – tripleee Apr 21 '23 at 12:18