2장. Deploying and configuring a Postfix SMTP server


As a system administrator, you can configure your email infrastructure by using a mail transport agent (MTA), such as Postfix, to transport email messages between hosts by using the SMTP protocol. Postfix is a server-side application for routing and delivering mail. You can use Postfix to set up a local mail server, create a null-client mail relay, use a Postfix server as a destination for multiple domains, or choose an LDAP directory instead of files for lookups.

The postfix package provides multiple configuration files in the /etc/postfix/ directory.

To configure your email infrastructure, use the following configuration files:

  • main.cf: contains the global configuration of Postfix.
  • master.cf: specifies Postfix interaction with various processes to accomplish mail delivery.
  • access: specifies access rules, for example hosts that are allowed to connect to Postfix.
  • transport: maps email addresses to relay hosts.
  • aliases: contains a configurable list required by the mail protocol that describes user ID aliases. Note that you can find this file in the /etc/ directory.

The key features of Postfix:

  • Security features to protect against common email related threats
  • Customization options, including support for virtual domains and aliases

2.1. Installing and configuring a Postfix SMTP server

You can configure your Postfix SMTP server to receive, store, and deliver email messages. If the mail server package is not selected during the system installation, Postfix will not be available by default. Perform the following steps to install Postfix:

Prerequisites

Procedure

  1. Remove the Sendmail utility:

    # dnf remove sendmail
  2. Install Postfix:

    # dnf install postfix
  3. To configure Postfix, edit the /etc/postfix/main.cf file and make the following changes:

    1. By default, Postfix receives emails only on the loopback interface. To configure Postfix to listen on specific interfaces, update the inet_interfaces parameter to the IP addresses of these interfaces:

      inet_interfaces = 127.0.0.1/32, [::1]/128, 192.0.2.1, [2001:db8:1::1]

      To configure Postfix to listen on all interfaces, set:

      inet_interfaces = all
    2. If you want that Postfix uses a different hostname than the fully-qualified domain name (FQDN) that is returned by the gethostname() function, add the myhostname parameter:

      myhostname = smtp.example.com

      For example, Postfix adds this hostname to header of emails it processes.

    3. If the domain name differs from the one in the myhostname parameter, add the mydomain parameter:

      mydomain = example.com
    4. Add the myorigin parameter and set it to the value of mydomain:

      myorigin = $mydomain

      With this setting, Postfix uses the domain name as origin for locally posted mails instead of the hostname.

    5. Add the mynetworks parameter, and define the IP ranges of trusted networks that are allowed to send mails:

      mynetworks = 127.0.0.1/32, [::1]/128, 192.0.2.1/24, [2001:db8:1::1]/64

      If clients from not trustworthy networks, such as the internet, should be able to send mails through this server, you must configure relay restrictions in a later step.

  4. Verify if the Postfix configuration in the main.cf file is correct:

    # postfix check
  5. Enable the postfix service to start at boot and start it:

    # systemctl enable --now postfix
  6. Allow the SMTP traffic through firewall and reload the firewall rules:

    # firewall-cmd --permanent --add-service smtp
    # firewall-cmd --reload

Verification

  1. Verify that the postfix service is running:

    # systemctl status postfix
    • Optional: Restart the postfix service, if the output is stopped, waiting, or the service is not running:

      # systemctl restart postfix
    • Optional: Reload the postfix service after changing any options in the configuration files in the /etc/postfix/ directory to apply those changes:

      # systemctl reload postfix
  2. Verify the email communication between local users on your system:

    # echo "This is a test message" | mail -s <subject> <user@mydomain.com>
  3. To verify that your mail server does not relay emails from external IP ranges to foreign domains, follow the below mentioned procedure:

    1. Log in to a client which is not within the subnets that you defined in mynetworks.
    2. Configure the client to use your mail server.
    3. Try to send an email to an email address that is not under the domain you specified in mydomain on your mail server. For example, try to send an email to non-existing-user@redhat.com.
    4. Check the /var/log/maillog file:

      554 Relay access denied - the server is not going to relay.
      250 OK or similar - the server is going to relay.

Troubleshooting

  • In case of errors, check the /var/log/maillog file.
Red Hat logoGithubredditYoutubeTwitter

자세한 정보

평가판, 구매 및 판매

커뮤니티

Red Hat 문서 정보

Red Hat을 사용하는 고객은 신뢰할 수 있는 콘텐츠가 포함된 제품과 서비스를 통해 혁신하고 목표를 달성할 수 있습니다. 최신 업데이트를 확인하세요.

보다 포괄적 수용을 위한 오픈 소스 용어 교체

Red Hat은 코드, 문서, 웹 속성에서 문제가 있는 언어를 교체하기 위해 최선을 다하고 있습니다. 자세한 내용은 다음을 참조하세요.Red Hat 블로그.

Red Hat 소개

Red Hat은 기업이 핵심 데이터 센터에서 네트워크 에지에 이르기까지 플랫폼과 환경 전반에서 더 쉽게 작업할 수 있도록 강화된 솔루션을 제공합니다.

Theme

© 2026 Red Hat
맨 위로 이동