Bootstrap FreeKB - Postfix (Email) - Create a users email address and inbox
Postfix (Email) - Create a users email address and inbox

Updated:   |  Postfix (Email) articles

There are two main ways that Postfix can be configured to create and store a users emails.

  • mbox
  • maildir (store the emails as files on the Postfix server)

To use maildir, so that emails are stored at /home/username/Maildir/, ensure your Postfix configuration file /etc/postfix/main.cf has the following. This will ensure that when a new user account is created, the new users home directory will contain the mail directory, such as /home/jane.doe/Maildir/.

home_mailbox    = Maildir/
mailbox_command =
mydomain        = example.com
mydestination   = example.com, localhost.example.com, localhost
myorigin        = $mydomain

 

In this scenario, when creating a new user account on the system using the useradd command, the users home directory will contain the Maildir directory. For example, let's say you create John Doe's user account.

useradd john.doe

 

However, when listing the contents of John Doe's home directory, John Doe's home directory will be empty (no files, no sub directories).

~]# ls -l /home/john.doe

 

Let's send an email to john.doe@example.com using the mail command.

mail "Hello World" | -s "Testing" john.doe

 

The Postfix log should now contain something like this.

Mar 06 11:31:37 post postfix/local[177]: 725FC12D34A: to=<john.doe@example.com>, relay=local, delay=0.03, delays=0.01/0/0/0.02, dsn=2.0.0, status=sent (delivered to mailbox)

 

And now John Doe's home directory should contain the following sub directories. Postfix creates the Maildir directory and sub directories after the first email is sent to the user.

/home/john.doe/Maildir/cur
/home/john.doe/Maildir/new
/home/john.doe/Maildir/tmp

 

And the new directory should have one file, for the email that was sent to John Doe.

/home/john.doe/Maildir/new/1448670731.V803I6c004bM330351.example.com

 

By default, the $MAIL environment variable is probably set to /var/spool/mail/username.

~]$ echo $MAIL
/var/spool/mail/john.doe

 

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter aec944 in the box below so that we can be sure you are a human.