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 “https://www.virtualbox.org/wiki/Downloads”.
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 “https://www.centos.org/download/”.
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 “main.cf” is adapted from an example found at the URL “https://unix.stackexchange.com/questions/13995/configure-postfix-to-send-and-receive-to-and-from-localhost”.)
cp /etc/postfix/main.cf /etc/postfix/main.cf.original echo "myorigin = localhost" > /etc/postfix/main.cf echo "mydestination = localhost.localdomain" >> /etc/postfix/main.cf echo "mynetworks = 127.0.0.0/8" >> /etc/postfix/main.cf echo "relayhost = " >> /etc/postfix/main.cf 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 exit su - tweedledum mail
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.