Thursday, February 10, 2011

Setting Up Mail Server on Linux [Postfix + Dovecot]

Hello Friends,

Here are the steps to configure a basic mail server using Postfix and Dovecot.
For the basics of Mail server you can refer Wikipedia. We need to download Postfix and dovecot. Generally with any Linux these packages are distributed by default but if not available can be downloaded and installed.

This document assumes that all commands are run using super user or root.

For Redhat/Fedora/Mandriva/Suse etc Linux flavours  
  • rpm -ivh postfix-Xx.XX.rpm
  • rpm -ivh dovecot-xx.xx.rpm

For Ubuntu/Debian
  • apt-get install postfix
  • apt-get install dovecot 

Configure your domain name.
  • If you are running on any system which is directly visible to Internet i.e. you have your domain name then use your domain.
  • My system is running on intranet/LAN so I have to configure a domain name in hosts file
    • Add this line to /etc/hosts
      •    rkg.test
    • You can choose the domain name according to you. I use .test because that is not gonna conflict with any website I open. 

Configure SMTP which runs on port 25 by default
  • Using your favorite editor edit /etc/postfix/ file 
    • vi  /etc/postfix/
  • Add these lines at the end
    • myhostname = rkg.test
    • mydomain = rkg.test
    • inet_interfaces = all
    • mynetworks = 
  • These are the basic configurations. If you want to get into details just read file accordingly.
  • mynetworks should be configured accordingly. For basics like > My system is in intranet with private LAN with IPs starting from so I put it like that. Choose according to your network.

Configure Dovecot for mail receiving protocols- imap imaps pop3 pop3s
  • Edit the /etc/dovecot.conf or sometimes at /etc/dovecot/dovecot.conf
    • vi /etc/dovecot.conf
  • add this line
    • protocols = imap imaps pop3 pop3s 
  • For advanced configurations modify dovecot.conf file.

Now we need to configure accounts. 

Add some system accounts like a, b, c etc.
  • useradd a
  • passwd a 
  • useradd b
  • passwd b
For these accounts emails will be a@rkg.test, b@rkg.test etc.

Now we need to start the servers -
  • service dovecot start 
  • service postfix start

To automatically start the servers at startup
  • chkconfig dovecot on
  • chkconfig postfix on
Now the mail server is up. You can now use it for your integration purposes. In next post we will see how Evolution can be used as mail client to verify what we just did. :)

Ravi Kumar Gupta -aka- D'Maverick


  1. i want you explain me more focus on mail server configuring using postfix

    1. Hi, Great.. Tutorial is just awesome..It is really helpful for a newbie like me.. I am a regular follower of your blog. Really very informative post you shared here. Kindly keep blogging. If anyone wants to become a Front end developer learn from JQuery Training in Chennai . or learn thru JQuery Training . or learn thru ES6 Online Training. Nowadays JavaScript has tons of job opportunities on various vertical industry.

  2. Hi,

    Thank you for your page.
    Recently I setup a homemade e-mail server and wrote a full detailed tutorial that you can find in

    using Debian Squeeze, Postfix, Dovecot, SASL, Spamassassin and Squirrel (and a Google account for SMTP relay).

    I wish it is helpful to someone.

  3. Generally, the public serves as a mix of their potential and existing clients. There are hidden prospects everywhere and you will lower your chances of reaching them if you lack an online identity.$1 Hosting


    not open link.

    Please inform me

  5. setting up mail server on the linux was an great and awesome topic. there is $1 web hosting if you idea that how to transfer an domain to another hosting.