Difference between revisions of "Postfix Local Mail"

From ArchWiki
Jump to: navigation, search
m (Step 3: Edit /etc/postfix/aliases)
m (Step 3: Edit /etc/postfix/aliases)
Line 54: Line 54:
 
  postalias /etc/postfix/aliases
 
  postalias /etc/postfix/aliases
  
In addition, create .forward in /root with the contents of the user you want to forward all root mail to:
+
In addition, create the file .forward in /root.
eg USER@localhost
+
 
 +
# nano /root/.forward
 +
 
 +
In it, specify the user to whom root mail should be forwarded, e.g. ''user@localhost''.
  
 
===Step 4: Start the daemon===
 
===Step 4: Start the daemon===

Revision as of 01:12, 21 May 2010

Template:Moveto The goal of this article is to setup Postfix for local mailbox delivery only. See: Postfix for a virtual mail delivery configuration.

Postfix Installation

Install Template:Package Official package with pacman:

# pacman -S postfix

Make sure that the following shows up in /etc/passwd

postfix:x:73:73::/var/spool/postfix:/bin/false

Make sure that the following shows up in /etc/group

postdrop:x:75:
postfix:x:73:
Note: Even though Postfix can be made to run in a chroot, this document does not currently cover such setups.

Postfix Configuration

Step 1: Edit /etc/postfix/main.cf

The only things you need to change are as follows. Uncomment them and modify them to the specifics listed below. Everything else can be left as installed by pacman.

inet_interfaces = loopback-only
mynetworks_style = host
append_dot_mydomain = no
default_transport = error: Local delivery only!

If you want to control where the mail gets delivered and which mailbox format is to be used, you can do this by setting

home_mailbox = /some/path 

or

mail_spool_directory some/path

mail_spool_directory is an absolute path where all mail goes, while home_mailbox specifies a mailbox relative to the user's home directory. If the path ends with a slash ('/'), messages are stored in Maildir format (direcory tree, one message per file); if it doesn't, the mbox format is used (all mail in one file).

Examples:

mail_spool_directory = /var/mail  (1)
home_mailbox = Maildir/           (2)

1) All mail will be stored in /var/mail, mbox format

2) Mail will be saved in ~/Maildir, Maildir format

Step 2: Edit /etc/rc.conf

Add postfix to the daemons list. Make sure you put it after the network has started.

DAEMONS=(syslog-ng network netfs crond postfix)

Step 3: Edit /etc/postfix/aliases

Namely, put a username in for the the following, substituting the correct username you desire (actual system account required) for USER

# Person who should get root's mail. Don't receive mail as root!
root:           USER

Run the following command as root. This creates the map file that postfix understands.

postalias /etc/postfix/aliases

In addition, create the file .forward in /root.

# nano /root/.forward

In it, specify the user to whom root mail should be forwarded, e.g. user@localhost.

Step 4: Start the daemon

postfix check

If postfix check returns no errors, then start the daemon.

/etc/rc.d/postfix start

Check /var/log/mail.log for any errors.

Step 5: Test

Try sending an email. Even from yourself to yourself should be a good test.

mail -s test user
this is a test email.
.

Now check your mail using whatever client you desire.

Step 6: Test some more!

Make sure root mail forwards to the desired user; use the same test as above, but substitute root for user.