Share This:

I’ve written about setting up a LAMP Server in the past. Now I will want to talk about setting up an E-Mail server so you can send emails and recieve E-Mails with your server. Think of it like this. It is what Yahoo, AOL, Google and most other E-Mail providers have to be able to give you an E-Mail and when you set this server up then you can do just what they do.

First you will need a computer to setup as your mail server. If you already have that then your pretty good to go. Next you will need to install Fedora on that computer. You will need to use either the Net Installer version of Fedora or the DVD version of Fedora.




Installing Fedora from DVD.

If your computer has a DVD drive then this will probably be the easiest route for you to go with installing Fedora. I’ll assume you have downloaded the Fedora ISO image already. Now we will need to burn the image onto a Blank DVD. If your running Windows 7 or later this can be done by simply right clicking on the ISO image and choosing burn image to disk option.

Once you have burned the DVD place it into your DVD drive, and restart your computer to boot into the DVD. Run threw the usual process of installing the system. you can refer to my other posts if you need to. When you get to the section that ask what type of setup you want. Choose the minimal install section. Then finish the installation.

Configure Your Router

Their are several types of ports that the SMTP, POP & IMAP protocals use. However since the most common is port 25, and port 26 we will focus on these. In order for your server to be able to send and recieve mail outside of your local domain you will need to let your router know that the ports are safe to be opened. To do this you will need to login to your router.

Their are many types of routers and each one is different in the way you access the router. However the general process is pretty much the same. I will be using a Linksys router in this example. To access the Linksys router I open up my web browser and in the address bar I type the routers gateway IP Address. With Linksys routers this is 192.168.1.1 and this will ask me for my user name and password, which you should know. If you never set your user name and password up on a Linksys router the default user name is not set and the password is admin, I would recommend that once you login you change the password and add a user name. Then you locate the port management section of the router and open ports 25 and 26. After you have done this save the settings and logout of the router.

Install the Mail Server

Now that we have installed our Fedora system and configured our router we can start to install the mail server. To do this we will install the postfix software by typing the following.


sudo yum install postfix -y

Once postfix is finished installing we will need to configure it.To do this we will need our text editor. I like the nano text editor so if you don’t have nano you can install it by typing the following.


sudo yum install nano -y

Now that nano is installed we can access the postfix configuration file by typing the following.


sudo nano -w /etc/postfix/main.cf

You will see a bunch of example configurations in this file. Lets scroll down to line 75 in the file and we will see something that is commented out of the file. It should look like the following.


#myhostname = mail.example.com

We will remove the # and change the mail.example.com to the host name we will be using for sending emails with. For example we may want to make the line look like the following.


mydomain = mail.techmeout.org

Now we will go to line 83 and we will see another line that has also been commented out that looks like the following.


#mydomain = example.com

Lets uncomment that line and change it to our domain name we are currently using. In this example we will be using techmeout.org so we will make the line look like the following.


mydomain = techmeout.org

Now lets got to line 99 and uncomment the line that looks like the following.


#myorigin = $mydomain

After we have uncommented the line it should look exactly like the following.


myorigin = $mydomain

We will not use a domain name in that line. For example $techmeout is wrong.

Lets go to line 116 and change inet_interfaces to look like the following.


inet_interfaces = all

If inet_interfaces is already set to all then leave it as it is. Now lets go to line 164 and add the following to the file.


mydesitination = $myhostname, localhost.$mydomain, localhost, $mydomain

Now lets go to line the line 264 and uncomment it and change the information to be for your networks settings. The line will look something like the following..


#mynetworks = 127.0.0.1/8

And we will change the above line to look like the following.


mynetworks = 192.168.1.1/24

Please note that the above works for me but will need to be tweaked for your networks settings and IP addresses.

Now lets go to line 419 and uncomment the line that looks like the following.


#home_mailbox = Maildir

After you have uncommented the line it should look like the following.


home_mailbox = Maildir

Now lets go to line 548. We should see something like the following.


header_checks = regexp:/etc/postfix/header_checks

We will leave the line as it is and we wont touch it, but we will add a line directly below it that looks like the following.


body_checks = regexp:/etc/postfix/body_checks

After we have added the above line it should look exactly like the following.

header_checks = regexp:/etc/postfix/header_checks
body_checks = regexp:/etc/postfix/body_checks

Now on line 574 and we will add the following


smtpd_banner = $myhostname ESMTP

Now we will limit the size of messages and the size of our mailbox. This way things don’t get to full. To do this we will add the following lines.


message_size_limit = 10485760
mailbox_size_limit = 1073741824

Lets setup our SMTP Authorization settings.to do this we will add the following to the main.cf file.

smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noanonymous
smtpd_sasl_local_domain = $myhostname
smtpd_client_restrictions = permit_mynetworks,reject_unknown_client,permit
smtpd_recipient_restrictions = permit_mynetworks,permit_auth_destination,permit_sasl_authenticated,reject

After we have made all of the changes needed for the main.cf file we will save the changes by pressing CTRL + X andpressing Y to accept changes.

Now we will need to modify our header_checks file. To do this we will first need to open it up in our text editor by typing the following.


sudo nano -w /etc/postfix/header_checks

Now that our header_checks file is open lets add some headers that we will have our mail server reject. We can use regulair expressions here and we most likely will. An example of what we can add to this file is as following.

/^From:.[email protected]\.com/ REJECT

After we have added all of our header checks. We can save the file by pressing CTRL + X and then pressing Y to save our changes. After this we can now add additional checks to check the body of the E-Mail, To do this we will open up the body_checks by typing the following.

sudo nano -w /etc/postfix/body_checks

And we will add some regex info that we want our server to reject. For example we may want to reject anything that says we won money because we believe it may be spam. To do this we will add the following to the file.

you won /^$\d\d*.00

Now lets save the file by pressing CTRL + X and then pressing Y to accept the changes.

Now lets type the following into our terminal.


sudo systemctl stop sendmail.service
sudo systemctl disable sendmail.service

Now we will also type the following.

alternatives --config mta

The above command will output something similar to the following.

There are 2 programs which provide 'mta'.

Selection Command

-----------------------------------------------
*+ 1 /usr/sbin/sendmail.sendmail
2 /usr/sbin/sendmail.postfix

Enter to keep the current selection[+], or type selection number:

Now we can change to postfix. To do this we will press the number 2 on our keyboard then we will press ENTER on our keyboard.




Now lets start and enable the postfix services. To do this we will type the following two commands.


sudo systemctl start postfix.service
sudo systemctl enable postfix.service

We should now have a fully operational mail server on our Fedora Linux system using the Postfix mail server program.