Setup Mail Server using Postfix, Dovecot and SquirrelMail in CentOS

  • uday

    this tuto is gr8. But can you help on Virtual Domain , with multiple emails ids,,

  • Bardia

    The best tutorial I have ever found! Thank you so much 🙂

  • Hi,
    Thanks for that tutorial.

    I’ve the trouble that I can only send emails to the address on the server, when I send to an email outside my server like to gmail, hotmail,… I don’t receive anyone.
    An other problem is that when I send to from the user1 receive duplicate the email.

    What I do wrong in the configuration?

    If I set up again the iptables it doesn’t work so the iptables is always disable, so How can I do to turn on again the iptables and selinux to have protect my server and continue going on the mail server?


    Best regards 😉

    • SK

      Hi Dasanro

      You need a static(Real) IP and the IP Address should be point to your mail domain. Also you need to add the valid MX records of Mail server in your DNS server. Get help from your ISP(Internet service provider). They will point your IP Address to your Mail domain.

      This should work. Hope this help you.

  • Todd Tolson

    Excelent tutorial. Followed to the letter and got the result expected. Problem being the newbie:
    when I attempt to send mail to external domains using the SquirrelMail Web interface this is what I get:

    Transaction failed
    554 5.7.1 : Relay access denied

    I do have a statice IP. I configured DNS at godaddy; A Record mail2 70.x.x.x; MX Record pri 0
    localhost.localdomain at install is:
    I believe my problem is with my understanding/execution of DNS. I used this great tutorial to set that up:
    with that as the basis, what changes do I make to get this working externally? The follow on will be: my intent is to further use this as a secondary mail server to spool mail when my failing exchange server goes down.
    Help! Thanks

    • SK

      Todd Have you seen this thread? Somebody had same problem and its solved.

      • Todd Tolson

        [SOLVED] A review of my logfiles revealed the “relay access denied” referrenced an IPv6 address. So, in the /etc/postfix/ file I changed line 116 to read: inet_interfaces = ipv4
        Viola! We have outgoinjg mail. With that fixed I had a primary mail server for that domain and setup/tested for use as a secondary mail server for four other domains I service MS Exchange Server for. GREAT setup – thanks again!

  • TS

    Hi SK. Thanks for posting your tutorial. I’m very appreciative and have gotten further due to your tutorials since I’m a newbie. I followed all steps and now I’m getting the same result as Todd Tolson. I did look at the thread you referenced and the parameters posted did not resolve the issue. Do you have any more insight to share? Thanks in advance.

    • Todd Tolson

      [SOLVED] A review of my logfiles revealed the “relay access denied” referrenced an IPv6 address. So, in the /etc/postfix/ file I changed line 116 to read: inet_interfaces = ipv4
      Viola! We have outgoinjg mail.

      • Todd Tolson

        Also, assuming you have a static external IP address, once you can send yourself mail to an external address you’ll need to contact your ISP so they cant create a PTR at their DNS servers so reverse DNS points to your mail server. Many exchanges check reverse DNS to validate your mail server is legitimate and if the banner doesn’t match they reject your mail.

      • SK

        Great find Todd!! Glad it worked for you.

  • Saravanan

    This is very usful tutorial for me. And one more thing can u please say how to send from this mail server to other domain for Ex: my mailserver to other mail server like gmail or yahoo.can u please say the configuration details for me

    • SK

      You need a external static ip and ask your ISP to point your mail server IP address to your mail domain.

  • Saravanan

    i have 2 static ip address am using a airtel lease line they have proved me two external static ip address. now what i want to know is how to configure this process in my mail server.

    • Todd Tolson

      Assumption: You followed SK’s two tutorial’s exactly modifying only your domain information.

      First, can you send mail internally using SquirellMail? (eg. If yes, when you use SquirllMail to send mail to an external domain (gmail, yahoo) what error(s) do you get?

      Have you gone to your host provider and setup the DNS MX recorder to reflect your external address?

      Have you contacted your ISP to create a PTR record to resolve reverse DNS for your external IP to your MX domain?

    • SK

      @Saravanan follow Mr.Todd Tolson advice. His mail server is now up and running. All you need to do is contact your ISP provider and ask them to add a MX record of your mail server in their DNS servers. Then you will be able to send/receive mails to external domains. Good luck.

  • Fernando

    great tutorial mate! thank’s!

  • Sarge

    Nothing about spam protection. Maybe you could modify the tutorial to include something about that. Thanks alot for the great tutorial.

  • Jose

    I am so grateful for that tutorial. But what i want to know is that is it a must for me to have a DNS server configured on my LAN for the mail server to work, Do i also need to configure iptables on my mail server and if yes what commands must i configure.

  • Taylor

    Thanks a lot for the tutorial it helped me out a lot! I have configured everything on the Ubuntu server, and have setup a client Ubuntu system all within virtualbox. Now i am a rather confused as to what network settings the server and client machine should have (either NAT or Internal ?) because at the moment with both using NAT they cannot see/connect to one another. Also to note the Ubuntu server is set to dhcp instead of static within /etc/network/interfaces . Thanks a lot for the replies

  • SK


    Use SMTP. It should work.

  • shekh sohil

    Thanks sir

  • Baskar

    Hi Sir,
    Thanks for tutorial. and pls share many tips for Linux Configuration.

  • Sumith

    Hello Sk really great doc… thanks a lot friend

  • Lee

    Great tutorial! Thanks!

  • Ronald

    Great guide good sir. It worked!

  • Excellent tutorial!

    I am interesting how to run two mail domain on one linux instance. Is there any way to do this?

  • Rick

    Excellent tutorial!

  • raj

    This tutorial is very excellent.