CentOS - Mail Server- Installation

The base package for all of the mail articles will be Postfix. There are, of course, alternatives to Postfix, each with advantages and disadvantages and, without going into the differences, I have chosen Postfix due its relative ease of configuration.

As many of the future articles will concentrate on administrative issues and assume Postfix is already installed, let's go ahead and install it.

Following from preparing the Slice for our email setup, we can move onto installing postfix.


Installation is very easy (remember we are using CentOS for these articles):

sudo yum install postfix telnet mailx

Note that we also install telnet and mailx as they contain several tools we'll use to test and configure Postfix.



We now have Postfix installed on our slice so let's get it up and running.

sudo /etc/init.d/postfix start


At this stage, you can send emails from your application.

The preparation we did in the previous article and the Postfix installation shown above means that the very basics are already done.

Quick Test

Although we will look in more detail at sending mail in the next article, let's conduct a quick test to see if Postfix is actually sending mail.

You will need to send an email to a working email address using the 'mail' command:

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 subject 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 address@example.com
Subject: Test email from demoslice.com
Test body of the email.

No confirmation is given that the email has been sent (the logs will show the details) but...

You've Got Mail

Check the receiving email address and voila! a nice, fresh email with the subject 'Test email from demoslice.com'.

For many people, that is all you need to send mail from your application - especially if the only emails are notifications to the site administrator.

However, the next article will look in more detail at the settings in Postfix's main.cf file and what they mean. This can help in reducing the chances of your email being classed as spam or your Slice IP being blocklisted.


Installation of Postfix is very simple using the yum package manager.

Once installed, email can be sent straight away.

Article Comments:

Chris commented Sun Nov 29 05:52:13 UTC 2009:

I found (on CentOS 5.4) that I also had to set


It was set to localhost by default, resulting in the smtpd only accepting connections from the slice itself.

Holiday homes commented Wed Apr 07 21:42:13 UTC 2010:

A really nice post! Admire the very idea of the post - have never met such a proper and useful guide. Thanks for sharing!

Ferienhaus commented Tue Apr 13 00:11:04 UTC 2010:

"Test body of the email." Didn't get the tool with help of which to test

Parthyz commented Thu Jan 20 04:58:04 UTC 2011:

Very nice article.Thanks a lot.

louie commented Thu Jan 20 19:52:19 UTC 2011:

Attempted a test email to working hotmail address and got the following error: 554 5.0.0 Service Unavailable Tell your provider hotmail does not relay dynamically-assigned IP ranges. You can also refer your provider to httpA://mail_live.com/mail/troubleshooting.aspx#errors.

Jered commented Fri Jan 21 04:03:29 UTC 2011:

Louie, it's possible they're using Spamhaus's PBL. They add IP addresses belonging to hosting providers (like Slicehost) to the PBL automatically. If you go through this article on the Spamhaus PBL you'll find a link to check to see if you're on there and remove it quickly. If that's not the issue let me know, or email/chat with Slicehost support and we can help figure out what's going on.

Want to comment?

(not made public)


(use plain text or Markdown syntax)