Postfix Mailbox Changes
Server Training - Mail Server

Mailbox Locations

Changing mailbox locations is easy in Postfix.  You may or may not want users to store mail in their home directory.  You may or may not like mail stored in one large file.  You have your choice with Postfix.

Related Postfix Training
Postfix Configuration
Postfix Mail Server Design
Control SPAM with Postfix
Postfix Mailbox Changes
Postfix Mail Gateway
Postfix Mail Server Course
 Postfix Mail Statistics

8 Week Course for $499.95  ORDER NOW

 Don't Outsource Your Mail Server, Learn how to run it yourself!
Postfix Training

We specialize in helping companies become independent of outsourcing Linux services.
8 Week Course for $499.95  ORDER NOW

 

 

 

 

 

 

main.cf The defaults are in blue. Though they are commented out they are active.


# DELIVERY TO MAILBOX

# The home_mailbox parameter specifies the optional pathname of a

# mailbox file relative to a user's home directory. The default

# mailbox file is /var/spool/mail/user or /var/mail/user. Specify

# "Maildir/" for qmail-style delivery (the / is required).

#home_mailbox = Mailbox

#home_mailbox = Maildir/

# The mail_spool_directory parameter specifies the directory where

# UNIX-style mailboxes are kept. The default setting depends on the

# system type.

#mail_spool_directory = /var/mail

#mail_spool_directory = /var/spool/mail


Verify Mailbox Location

It is important to understand where mail is going. Use this command to find the current location of the mail directory for the user.

In this example you see that the user is accepting mail in the default location. This will be very handy for troubleshooting.

set | grep -i mail

MAIL=/var/spool/mail/mike

MAILCHECK=60


MailBox Location: MBOX

By default Linux will use MBOX as a method of creating a mailbox for each user. This location is at /var/spool/mail. After creating a few users here is an example:

ls -la /var/spool/mail

total 24

drwxrwxr-x 3 root mail 4096 Dec 18 00:10 .

drwxr-xr-x 11 root root 4096 Dec 12 13:39 ..

-rw-rw---- 1 mike mail 5292 Dec 18 00:13 mike

-rw-rw---- 1 sue mail 2925 Dec 16 15:51 sue

Notice that the two users each have a mailbox which they can pickup mail on the local system. Each user owns the mailbox and mail is the group. This is a Postfix default.


Change Location of Default Mailbox

Edit the main.cf file and the directive home_mailbox

There are two options here which are both commented out.  To change the user
mailbox so mail is delivered into the /home account of each user you will need to
uncomment the home_mailbox.

home_mailbox = Mailbox
#home_mailbox = Maildir/

Save and reload postfix.

This change will now have all of mike's mail delivered into /home/mike/mbox instead of the /var/spool/mail/mike location.

Now change the the default Mail variable for the user.

export MAIL=~/Mailbox


Change Location of Default Mailbox to MailDir

This method offers excellent scaling possibilities. This method contains one file per email.

Edit main.cf
There are two options here which are both commented out. To change the user
mailbox so mail is delivered into the /home account of each user you will need to
uncomment the home_mailbox to allow the Maildir/.

#home_mailbox = Mailbox
home_mailbox = Maildir/

Save and reload postfix.

Now change the the default Mail variable for the user. First you will need to uset the variable.

unset MAIL

Now export the new variable.

export MAILDIR=~/Maildir


# ls /home/mike/Maildir

cur new tmp

 


Copyright CyberMontana Inc. and BeginLinux.com
All rights reserved. Cannot be reproduced without written permission. Box 1262 Trout Creek, MT 59874