- Use SSL. You're passing credentials and private communications over the wire, so you'd better encrypt it.
- Don't be an open relay. Forwarding spammers' mail is a good way to get your IP blacklisted and receive some nastygrams from other webmasters
chroot
if possible.
I use Postfix and Dovecot. They're reasonably well-behaved.
sudo apt-get install postfix dovecot-imapd
That will get you the base packages necessary to get started.
Postfix is a popular and sensibly-written mail transfer agent (MTA). It's full-featured and fast.
main.cf
is Postfix's primary configuration file.
myhostname
: this mail server's hostnamemyorigin
: domain to use for locally-posted mail sending and deliverymydestination
: domains whose mail is handled by this servermynetworks
: trusted networks (i.e., the IP block(s) your other non-mail servers are in)relayhost
: domain to relay mail to when the destination is not a domain inmydestination
inet_interfaces
: the interfaces Postfix should listen on. Normally,all
home_mailbox
: the pathname to deliver mail to relative to a user's home directoryalias_maps
/alias_database
: aliases used for local mail delivery
- ``
# Use /etc/mailname to determine origin
myorigin = /etc/mailname
myhostname = mail.domain.net
# Accept mail for localhost and domain.net
mydestination = domain.net, mail.domain.net, localhost, localhost.localdomain
# Allow loopback deliveries and deliveries from a hypothetical server block
# at 192.168.1.0/24
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 192.168.1.0/24
# Don't relay mail not destined for here
relayhost =
# Listen on all interfaces
inet_interfaces = all
# Use qmail Maildir format
# -- qmail format used if name has a trailing /
home_mailbox = Maildir/
# Configure alias files
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
# Allow user+tag@domain.net style addressing
recipient_delimiter = +
# Set a connection banner
smtpd_banner = $myhostname ESMTP $mail_name
# Disable local mail notifications
biff = no
# Unlimited mailbox size
mailbox_size_limit = 0
Dovecot is one of the popular IMAP client access servers. Like Postfix, it has a rich feature set and solid performance.
If you're just doing email for a single domain, and you (or people you trust with local accounts) are the only user, you can just create the requisite system accounts and aliases and call it a day. Otherwise, you'll need to roll some of the virtual mail features of Postfix and Dovecot.