Facebook Twitter Instagram
    TecAdmin
    • Home
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    You are at:Home»Mail Servers»Postfix»How to Install Postfix on CentOS/RHEL 7/6/5

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

    By RahulMarch 8, 20132 Mins ReadUpdated: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.

    Advertisement

    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.

    email server mail mailserver Postfix smtp
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp

    Related Posts

    Postfix: Sending Emails From External SMTP Servers

    Postfix: Sending Emails From External SMTP Servers

    Postfix: Configure SASL Authentication for Remote SMTP

    Postfix: Configure SASL Authentication for Remote SMTP

    Postfix: Relay Email from SMTP based on From Address

    Postfix: Relay Outgoing Emails Based On Sender Address

    View 16 Comments

    16 Comments

    1. Prashant Jaiswal on August 9, 2021 5:33 pm

      totally not helpful. Completely vague and unclear solution. Left too much.

      Reply
    2. Pratik on July 15, 2019 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

      Reply
      • Daniel on July 25, 2019 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

        Reply
      • Shazeb ICT on March 11, 2021 5:04 am

        The above information is very helpful. Thanks, Pratik
        We know computer issues can happen at any time. That’s why we provide a 24-hour emergency IT support service. If you need us to resolve a frustrating IT issue after hours just call us and you will be working again in no time.

        Reply
    3. Ardiansyah on July 8, 2019 8:00 am

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

      Reply
    4. Jason on June 25, 2019 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

      Reply
    5. Blazho Dzurovski on July 7, 2018 11:40 pm

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

      Reply
    6. psd2 api on February 11, 2018 9:08 am

      Excellent. It works!

      Reply
    7. preeti on July 11, 2016 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

      Reply
    8. kazuya on June 11, 2014 12:18 am

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

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

        Thanks kazuya…

        Reply
      • P on August 18, 2015 11:05 am

        Is that all you noticed here Kazuya??

        Reply
    9. Murad Hosen on February 16, 2014 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

      Reply
    10. Todd on September 11, 2013 12:09 pm

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

      Reply
    11. NeverWinter gold on May 23, 2013 3:43 pm

      hello!this is extremely good site!

      Reply
    12. Jones sabo on April 14, 2013 3:31 pm

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

      Reply

    Leave A Reply Cancel Reply

    Advertisement
    Recent Posts
    • Backing Up Your Linux System with Rsync: A Step-by-Step Guide
    • Sort Command in Linux with Practical Examples
    • How to Install and Use Flask in Fedora 37/36
    • Sed Command in Linux with 15 Practical Examples
    • How to Print a List without Brackets in Python
    Facebook Twitter Instagram Pinterest
    © 2023 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.