Page tree
Skip to end of metadata
Go to start of metadata


This article outlines specifically how to use your server to send emails for server administration purposes only . Another term for this is setting up a null client.

For receiving emails and hosting it is recommend to use a dedicated mail server. Non-profits or small businesses should consider the using Google Apps which is free.

Install Postfix

Postfix is free and open-source mail transfer agent (MTA) that routes and delivers electronic mail. It is intended as a fast, easier-to-administer, and secure alternative to the widely-used Sendmail MTA.

sudo apt-get install postfix

Configuring Postfix

You will be provided a command line UI to selection some options.

Please select the mail server configuration type that best meets your needs. = Internet Site

The "mail name" is the domain name used to "qualify" _ALL_ mail addresses without a domain name. = (leave default is fine)

At the end,

Postfix is now set up with a default configuration.  If you need to make changes, edit
/etc/postfix/ (and others) as needed.  To view Postfix configuration
values, see postconf(1).

After modifying, be sure to run '/etc/init.d/postfix reload'.

I then modified the to add my MX record for mydestination,

# See /usr/share/postfix/ for a commented, more complete version

# Debian specific:  Specifying a file name will cause the first
# line of that file to be used as the name.  The Debian default
# is /etc/mailname.
#myorigin = /etc/mailname

smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
biff = no

# appending .domain is the MUA's job.
append_dot_mydomain = no

# Uncomment the next line to generate "delayed mail" warnings
#delay_warning_time = 4h

readme_directory = no

# TLS parameters
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache

# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
# information on enabling SSL in the smtp client.

smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
myhostname = t01app
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
mydestination =, t01app, localhost.localdomain, , localhost
relayhost =
mynetworks = [::ffff:]/104 [::1]/128
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
inet_protocols = all

When time available write up more on these options, ie how I setup my MX record on my domain server to use Google's email service.

Basics of Postfix

Default installations of Postfix stores all messages in an mbox file. To see what directory it is using use the command,

sudo postconf mail_spool_directory
mail_spool_directory = /var/mail # This is the default directory.

The newer maildir format is now recommened so follow the next section to change to maildir.

Setup Mail Delivery Account

The overall consensus is to use the maildir format with a mail directory being used for each user.

Backup /etc/postfix/ in case something goes wrong. All the subsequent commands modify,

sudo cp /etc/postfix/ /etc/postfix/

The following command will do make the following changes,

  • Set emails to the users home directory under a subfolder called Maildir.
  • The trailing slash indicating a folder, will configure Postfix to use the maildir format. Note, if you forge the slash, a file called maildir will be generated in mbox format.
sudo postconf -e 'home_mailbox = Maildir/'

In most cases, your system is being used to send email outbound and not receive email or deliver the emails locally to the system.

sudo postconf -e "inet_interfaces = loopback-only" # receive no mail from the network, and do not deliver any mail locally


Reverse DNS

TBC - This should explain why we would want reverse dns.

Reverse DNS unless delegated is managed by the ISP provider. Generally this means whoever manages the IP address of your server.

Setup spf Records

TBC - This section should be filled out with a general discussion of what spf is for and how to configure within Rackspace or your registrar.


Here is how to send a test email.

First install a simple mail program. In this example we will use mailx,

sudo apt-get install bsd-mailx

Next send the email,

echo "test" | mail -s testsubject

The log for a valid send will look something like this,

tail /var/log/mail.log
Jun 23 22:06:38 krypton postfix/pickup[15174]: AA67C2F824D: uid=2500 from=<tinpham>
Jun 23 22:06:38 krypton postfix/cleanup[15988]: AA67C2F824D: message-id=<20110624020638.AA67C2F824D@myra>
Jun 23 22:06:38 krypton postfix/qmgr[15175]: AA67C2F824D: from=<>, size=294, nrcpt=1 (queue active)
Jun 23 22:06:39 krypton postfix/smtp[15990]: AA67C2F824D: to=<>,[]:25, delay=1, delays=0.02/0.01/0.25/0.74, dsn=2.0.0, status=sent (250 ok dirdel)
Jun 23 22:06:39 krypton postfix/qmgr[15175]: AA67C2F824D: removed

If you do not see your receive your test email, try looking in your spam folder.

References - How to setup postfix - Deciding on Mbox vs Maildir - Syrus vs Dovecot - Slicehost instructions on postfix, has notes here about reverse dns being needed - Rackspace instructions on postfix, the Slicehost actually seems better - talks about null client

  • No labels