This guide will cover the basic installation and configuration of Postfix, Maildrop and IMAP by using the built-in Advanced Packaging Tool (apt-get) for Debian.
Make sure you have your apt-get sourcelist updated before you start so you receive the lastest packages.
You will need following packages:
Postfix MTA
- Mailsystem
Maildrop
- Mail delivery agent
Courier IMAP
- IMAP server so we can connect to our system using an e-mail client or a webmail system.
Step 1 – Receive and install the packages:
# apt-get install postfix
# apt-get install courier-imap
# apt-get install maildrop
If everything went allright, you now have the packages installed.
Step 2 – Postfix configuration:
The Postfix configuration directory is located in “/etc/postfix”, and the main configuration file is called “main.cf”.
Use nano or your favorite editor.
# nano /etc/postfix/main.cf
Add the following:
myhostname = <mail.yourdomain.com> # Add your domain here.
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = <yourdomain.com>, localhost # Add your domain here.
relayhost = <smtp.yourisp.com> # Add this if you wish to forward outgoing mail to your ISPs smtp, otherwise leave blank.
home_mailbox = Maildir/ # Value is appended to the user’s home directory path.
mailbox_command = /usr/bin/maildrop -d “$USER” -f “$SENDER” “$EXTENSION” # Give the job to maildrop.
mailbox_size_limit = 0 # With this setting, users will not have a mailbox limit.
recipient_delimiter = +
inet_interfaces = all
Step 3 – Create email user:
# adduser -shell /sbin/nologin emailuser
# passwd emailuser
# cd /home/emailuser (as root)
# maildirmake Maildir
This will give the emailuser no access to shell logins.
Mail will now be delivered to /home/emailuser/Maildir.
Step 4 – Forwarding
Since maildrop is mail delivery agent, you need to edit /etc/aliases and specify where you want mail to root user to be delivered.
# nano /etc/aliases
And change: root: nobody to root: emailuser
Example:
If you want to forward emails that are sent to “emailuser2@<yourdomain.com>” to “emailuser@<yourdomain.com>”
Add:
emailuser2: emailuser
Run the command
# newaliases
Reload Postfix:
# /etc/init.d/postfix stop
# /etc/init.d/postfix start
Start Courier-IMAP:
# /etc/init.d/courier-imap start
Remember to check that you have port 143 open for incoming IMAP connections.
Setup your favorite email client and you should now be able to receive incoming mails to emailuser@yourdomain.com with the proviso that you have the DNS settings of your domain right.