Creating a simple mail server

From Newroco Tech Docs
Jump to navigationJump to search

This page describes how to install and configure a simple email server, supporting SMTP, IMAP and POP3. The basic configuration utilises plain text passwords and would not be suitable for deployment on an Internet facing server i.e. as described it should be behind a firewall with no direct port forwards for any of the services (though SMTP would be an acceptable risk).

Mail systems install

starting with base 14.04.4 VM on 8GB vdisk and 1GB RAM

email service to receive emails for "auto" forum posting and send notification emails to users. This receive part will be prevented from being access from outside the local server.

All commands assumed with sudo or having already acquired root-level privileges

install email server

apt-get install postfix

postfix configured as Internet site with smarthost, with domain name and smarthost as (if you are sending email direct to destination domains you don't need the smarthost setting).

apt-get install dovecot-core dovecot-pop3d dovecot-imapd

apt-get install libsasl2-2 libsasl2-modules sasl2-bin

set saslauthd to start on boot:

vi /etc/default/saslauthd


For testing purposes install mailx

apt-get install mailx

Setting up postfix for virtual (non-system) mail users:

groupadd -g 5000 vmail

useradd -m -u 5000 -g 5000 -s /bin/bash vmail

check dovecot has right access to mail directory, locations and mail storage format and enable a system wide user:

vi /etc/dovecot/conf.d/10-mail.conf

Uncomment and amend:

mail_location = maildir:~/

mail_privileged_group = mail

mail_uid =vmail
mail_gid =vmail

Configure postfix for virtual mail user use:

vi /etc/postfix/

and append

virtual_mailbox_domains = /etc/postfix/vhosts
virtual_mailbox_base = /var/mail/vmail
virtual_mailbox_maps = hash:/etc/postfix/vmaps
virtual_minimum_uid = 1000
virtual_uid_maps = static:5000
virtual_gid_maps = static:5000

Add the vmail directory as specified above:

mkdir /var/mail/vmail

and give ownership to the vmail user

chown vmail:vmail /var/mail/vmail

Add the vhosts file:

vi /etc/postfix/vhosts

adding the "@" domains to support, one per line: