Sending a Local Email with CentOS and Postfix

Follow the steps below to send an email from one user on a CentOS machine to another user on that same machine.

1. If you already have a working CentOS installation running Postfix, skip to step 6. Otherwise, proceed to the next step to create a virtual machine running CentOS.

2. If you have not already done so, download and install a virtualization hypervisor, such as VirtualBox. As of this writing, the latest version is available for download at the URL “”.

3. Download an ISO of CentOS. CentOS is a free and open source operating system based on the Linux kernel. As of this writing, the latest version of CentOS can be obtained at the URL “”.

4. Start the hypervisor and create a new virtual machine named “PostfixTest”. When prompted, select the CentOS ISO downloaded in the previous step as the boot media.

5. Proceed through the necessary steps to install CentOS, and then restart the virtual machine if necessary. Remember to “eject” the CentOS ISO from the virtual machine’s drive before rebooting, or otherwise it will attempt to install CentOS again.

6. In CentOS, open a console window and switch to the root user by entering the “su” command and supplying the correct password.

7. At the console prompt, enter the following commands. (The text of the configuration file “” is adapted from an example found at the URL “”.)

cp /etc/postfix/ /etc/postfix/

echo "myorigin = localhost" > /etc/postfix/
echo "mydestination = localhost.localdomain" >> /etc/postfix/
echo "mynetworks =" >> /etc/postfix/
echo "relayhost = " >> /etc/postfix/

service postfix restart

useradd tweedledee
useradd tweedledum

yum install -y mail

su - tweedledee
echo "This is a test." | mail -s "Local Email Test" tweedledum@localhost

su - tweedledum

8. Inside the mail program, verify that the user tweedledum has a message in the inbox. Press the “1” key to read it, and verify that it has the expected text.

8. Press the “q” key to quit the mail program.

This entry was posted in Uncategorized and tagged , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s