Postfix

Prerequisites

  • Set the hostname
  • Set the reverse DNS
  • Ensure dnsutils ar installed
sudo aptitude install dnsutils

Check Reverse DNS

To check if RDNS propagated already:

dig -x 123.45.6.78

If "ANSWER SECTION" still shows the old name (or anything other than your server hostname) - you'll have to wait until propagation will finish before proceeding.

Install Postfix

sudo aptitude install postfix

During the installation you will be asked the general type of mail configuration. Choose the 'Internet Site' option.

You will then need to enter your main domain name. This should match the reverse DNS.

Configuration

Edit the main Postfix configuration file:

sudo nano /etc/postfix/main.cf

You are looking to override the following variable values, replacing yourdomain.com and host.yourdomain.com:

mydomain = yourdomain.com
myorigin = $mydomain
myhostname = host.yourdomain.com

Update the networks value:

Replace this: mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
with this: mynetworks = 127.0.0.0/8

Restart postfix to make changes take effect:

sudo /etc/init.d/postfix restart

SPF Records

The purpose of Sender Policy Framework (SPF) Text is to allow a mail server to validate that the sending mail server is authorized to send mail on behalf of a domain. Having an SPF record can reduce email fraud and forged email.

If your Linode is going to send out mail on behalf of your domain and it is not explicitly listed as the destination for your domain or the MX records then you are advised to add an SPF record to your DNS.

A good place to help you construct your SPF record is to use the wizard located on the official SPF home page - http://www.openspf.org/

Test Send

There are two methods described here for testing mail sending from your server. One uses the mail command the other telnet.

Mail Command Method

Install the mail command:

sudo aptitude install mailx

Send the test mail:

mail address@example.com

Replace the email address with one of your choosing (remember this must be a working email address).

The output asks for the subject of the email. Once done, press enter/return.

Next enter the body of the email. Once done, press enter/return and then a single period (.) - the period lets mail know the body is finished.

Finally press enter/return again to send the email (you may need to do this twice so you skip the 'CC:' entry.

The output on my machine looks something like this:

mail user@example.com
Subject: test email from my linode
test body of the email.
.
Cc:

Telnet Method

Telnet is not installed by default, so to install it use the following command:

sudo aptitude install telnet

To open a telnet session into Postfix then issue:

telnet localhost 25

Trying 127.0.0.1...
Connected to host.yourdomain.com.
Escape character is '^]'.
220 host.yourdomain.com ESMTP Postfix

Where host.yourdomain.com should appear as the FQDN of your server. Now identify the the server by typing the following:

HELO host.yourdomain.com

This should yield a 250 host.yourdomain.com response.

Now set the sending email address:

MAIL FROM: <name@yourdomain.com>

This should yield a 250 2.1.0 Ok or similar response.

Now set the email address of the recipient:

RCPT TO: <user@example.com>

This should also yield a 250 2.1.0 Ok or similar response.

Now you can enter the body of the message. Type typing:

DATA

This will display the 354 End data with <CR><LF>.<CR><LF> response. Simply type a message, hit return and enter a full stop on a line of it's own then hit return again. This should send the email out.

You can either send another email by starting with the HELO instruction, or quit by typing:

QUIT

Now check the mail account of the recipient to see it has arrived okay.

References

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License