• Home
  • Ubuntu 18.04
    • Whats New?
    • Upgrade Ubuntu
    • Install Java
    • Install Node.js
    • Install Docker
    • Install Git
    • Install LAMP Stack
  • Tutorials
    • AWS
    • Shell Scripting
    • Docker
    • Git
    • MongoDB
  • Funny Tools
  • FeedBack
  • Submit Article
  • About Us
TecAdmin
Menu
  • Home
  • Ubuntu 18.04
    • Whats New?
    • Upgrade Ubuntu
    • Install Java
    • Install Node.js
    • Install Docker
    • Install Git
    • Install LAMP Stack
  • Tutorials
    • AWS
    • Shell Scripting
    • Docker
    • Git
    • MongoDB
  • Funny Tools
  • FeedBack
  • Submit Article
  • About Us

How to Install Postfix on CentOS/RHEL 7/6/5

Written by Rahul, Updated on February 18, 2019

Postfix is fast and popular SMTP server widely used. The main job of postfix is to relay mail locally or to the intended destination outside the network. Some of the most popular SMTP servers are Sendmail, Postfix, and Qmail. By default, Sendmail comes pre-installed with CentOS/RHEL 5. We will need to remove it and install Postfix.

You may also like:

  • Install Postfix on Ubuntu

Step 1 – Install Postfix

If Postfix not already installed on your machine, Install it using the following command. Also, remove sendmail if already installed.

yum remove sendmail
yum install postfix

Make postfix as default MTA for your system using the following command

alternatives --set mta /usr/sbin/postfix

If above command not work and you get the output as “/usr/sbin/postfix has not been configured as an alternative for mta“. Use below command to do the same else skip it

alternatives --set mta /usr/sbin/sendmail.postfix

Step 2 – Configure Postfix

Let’s start postfix configuration. Edit Postfix configuration file /etc/postfix/main.cf in your favorite editor and make following changes.

  myhostname = mail.tecadmin.net
  mydomain = tecadmin.net
  myorigin = $mydomain
  inet_interfaces = all
  mydestination = $myhostname, localhost, $mydomain
  mynetworks = 127.0.0.0/8, /32
  relay_domains = $mydestination
  home_mailbox = Maildir/

After executing above command edit the postfix configuration file and make sure all changes are done properly.

Step 3 – Restart Postfix Service

As we have done basic Postfix configuration, So restart Postfix service to read changes of configuration. Also, configure to autostart on system boot.

service postfix restart
chkconfig postfix on

Step 4 – Open Firewall Port

Now if your system is configured to use iptables firewall, So add firewall rules to make postfix accessible from outside, using following commands.

iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 25 -j ACCEPT
iptables -A INPUT -m state --state NEW -m udp -p udp --dport 25 -j ACCEPT

Thanks for using this article.

Share it!
Share on Facebook
Share on Twitter
Share on LinkedIn
Share on Reddit
Share on Tumblr
Share on Whatsapp
Rahul
Rahul
Connect on Facebook Connect on Twitter

I, Rahul Kumar am the founder and chief editor of TecAdmin.net. I am a Red Hat Certified Engineer (RHCE) and working as an IT professional since 2009..

14 Comments

  1. Avatar Pratik Reply
    July 15, 2019 at 8:30 am

    Hi,

    I am not sure how many of the readers were successfully able to get the Postfix started sending emails…

    I followed all the steps of the article. When I try sending test mail, I get following error in the /var/log/maillog

    Jul 15 12:08:46 mumsrv-qe postfix/pickup[28935]: CD221181C6E: uid=0 from=
    Jul 15 12:08:46 mumsrv-qe postfix/cleanup[30412]: CD221181C6E: message-id=
    Jul 15 12:08:46 mumsrv-qe postfix/qmgr[28936]: CD221181C6E: from=, size=479, nrcpt=1 (queue active)

    Jul 15 12:09:28 mumsrv-qe postfix/smtp[30414]: CD221181C6E: to=, relay=mobileum.com[217.78.11.57]:25, delay=42, delays=0.11/0.01/21/21, dsn=5.0.0, status=bounced (host mobileum.com[217.78.11.57] said: 550-Please turn on SMTP Authentication in your mail client. 550-(mumsrv-qe.mobileum.com) [114.143.191.38]:43898 is not permitted to relay 550 through this server without authentication. (in reply to RCPT TO command))
    Jul 15 12:09:28 mumsrv-qe postfix/cleanup[30412]: 6DAE3181C88: message-id=
    Jul 15 12:09:28 mumsrv-qe postfix/bounce[30494]: CD221181C6E: sender non-delivery notification: 6DAE3181C88
    Jul 15 12:09:28 mumsrv-qe postfix/qmgr[28936]: 6DAE3181C88: from=, size=2718, nrcpt=1 (queue active)
    Jul 15 12:09:28 mumsrv-qe postfix/qmgr[28936]: CD221181C6E: removed

    I am not sure what is missing!
    Someone please help

    • Avatar Daniel Reply
      July 25, 2019 at 8:15 am

      If you’re still having issues setting up Postfix please send me an email at [email protected] This article is very vague and completely not helpful to beginners. Personnaly i would suggest to use PostgreSQL as a Database backend over MySQL. feel free to email me if you or anyone else is having trouble setting up an email server

  2. Avatar Ardiansyah Reply
    July 8, 2019 at 8:00 am

    Thank For Yourt Information its very useful for me as a beginner

  3. Avatar Jason Reply
    June 25, 2019 at 4:52 am

    In Redhat 8 at least (and probably every other version/flavor), specifying a Subnet like l27.0.0.0/8, 32 will conflict with the earlier inet_interfaces=all statement. Can’t have both. Best to recomment the subnet line.

    Also, this article is woefully short and inadequate. You should thoroughly configure and test Postfix before making it your MTA. If you’re gonna go to the trouble of writing a config article, do it right ffs

  4. Avatar Blazho Dzurovski Reply
    July 7, 2018 at 11:40 pm

    Really great site I Must say something I applied regarding Outbound Telemarketing Cold Calling script for answering.

  5. Avatar psd2 api Reply
    February 11, 2018 at 9:08 am

    Excellent. It works!

  6. Avatar preeti Reply
    July 11, 2016 at 1:38 pm

    rcpt to:
    550 5.1.1 : Recipient address rejected: User unknown in local recipient table
    i receive above error please help to find out

  7. Avatar kazuya Reply
    June 11, 2014 at 12:18 am

    There is a Spelling Mistake serivce postfix restart it is service postfix restart

    • Rahul Rahul Reply
      June 11, 2014 at 2:39 am

      Thanks kazuya…

    • Avatar P Reply
      August 18, 2015 at 11:05 am

      Is that all you noticed here Kazuya??

  8. Avatar Murad Hosen Reply
    February 16, 2014 at 6:33 pm

    not sent outgoing mail ( gmail or hotmail.com )

    local mail are sent but not outgoing

    what can i do i am using centos 6.5 32 bit

  9. Avatar Todd Reply
    September 11, 2013 at 12:09 pm

    Wouldn’t it be better to configure Postfix *before* making it your MTA?

  10. Avatar NeverWinter gold Reply
    May 23, 2013 at 3:43 pm

    hello!this is extremely good site!

  11. Avatar Jones sabo Reply
    April 14, 2013 at 3:31 pm

    Excellent goods from you, man. I’ve understand your stuff previous to and you’re just extremely magnificent.

Leave a Reply Cancel reply

Popular Posts

  • How To Install Python 3.9 on Ubuntu 20.04 5
  • How to Install Python 3.9 on CentOS/RHEL 7 & Fedora 32/31 0
  • How To Install VNC Server on Ubuntu 20.04 1
  • How To Install NVM on macOS with Homebrew 0
  • How to Install .NET Core on Debian 10 0
© 2013-2020 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy