RHCE Series (ix): How to use the No client configuration Postfix

Source: Internet
Author: User
Tags mail server hosting server hosting

Reproduced in: http://www.itxuexiwang.com/a/liunxjishu/2016/0220/152.html?1456382561

Although there are many online contacts now, e-mail is still an effective way for someone to deliver information to another person who sits next to us at the end of the world or in the office.

The following figure depicts the delivery of an e-mail message from the sender until the message arrives in the recipient's Inbox.

How e-Mail works

There are a lot of things going on behind the scenes to achieve all this. In order for e-mail messages to be posted from a client application (such as Thunderbird, Outlook, or web mail service such as Gmail or Yahoo mail) to a mail server and sent from it to the target server and eventually to the target recipient, each server must have SMTP (Simple Mail Transfer Protocol) service.

That's why we're in this blog post. Describes how to set up an SMTP server in RHEL 7, send messages from local Users (even send to another local user) to be forwarded (forward) to a central mail server for easy access.

This is called a no-client (null-client) installation in the requirements of this exam.

An origin (originating) mail server and a central server or relay host (Relayhost) will be included in our test environment.

    • Originating Mail server: (host name: box1.mydomain.com/ip:192.168.0.18)
    • Central mail server: (host name: mail.mydomain.com/ip:192.168.0.20) #p # page Title #e#

We will use your familiar files for name resolution in both machines /etc/hosts :

192.168.0.18    box1.mydomain.com       box1192.168.0.20    mail.mydomain.com       mail

Installation Postfix and firewall/selinux considerations

First, we need (on two machines):

1, installation Postfix:

# yum update && yum install postfix

2. Start the service and enable startup automatically:

# systemctl start postfix# systemctl enable postfix

3. Allow mail traffic through the firewall:

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

Open the mail server port #p# The paging header in the firewall #e#

4, in box1.mydomain.com configuration Postfix

The main configuration file for Postfix is /etc/postfix/main.cf . The file itself is a large text file because it contains comments that explain the purpose of the program settings.

For brevity, we only show the lines that need to be edited (yes, you need to leave them blank in the origin server mydestination , otherwise the messages will be stored locally instead of the central mail server we actually want to send to):

myhostname = box1.mydomain.commydomain = mydomain.commyorigin = $mydomaininet_interfaces = loopback-onlymydestination =relayhost = 192.168.0.20

5, in mail.mydomain.com configuration Postfix

myhostname = mail.mydomain.commydomain = mydomain.commyorigin = $mydomaininet_interfaces = allmydestination = $myhostname, localhost.$mydomain, localhost, $mydomainmynetworks = 192.168.0.0/24, 127.0.0.0/8

If you have not set it yet, set the associated SELinux Boolean value to True permanently:

# setsebool -P allow_postfix_local_write_mail_spool on

Set Postfix SELinux Permissions

The above SELinux boolean value allows Postfix on the central server to write to the Mail pool (mail spool). #p # pagination Title #e#

6. Restart the service on both machines for the changes to take effect:

    1. #systemctl restart postfix

If Postfix does not start correctly, you can use the following command for error handling.

    1. #systemctl-l status postfix
    2. #journalctl-xn
    3. # postconf -n

Test Postfix Mail Service

To test the mail server, you can use any Mail user agent (mail users Agent,mua), such as mail or mutt.

As I personally like Mutt, I will use it in Box1 to send mail to the user Tecmint, and the existing file (Mailbody.txt) as the information content:

    1. # mutt -s "Part 9-RHCE series" [email protected].com < mailbody.#p#分页标题#e#txt

Test Postfix Mail Server

Now log in to the central mail server (mail.mydomain.com) to tecmint the user and check if the message was received:

    1. #su– tecmint
    2. # mail

Check Postfix mail server send

If you do not receive the message, check the root user's message pool to see if there are any warnings or error prompts. You may need to use the Nmap command to make sure that the SMTP service is running on both servers and that port 25th is open in the central mail server:

    1. #nmap-PN 192.168.0.20

#p # pagination Title #e#

Postfix Mail Server error handling

Summarize

Setting up mail servers and relay hosts, as shown in this article, is an important skill that every system administrator must have, and also represents the basis for understanding and installing more complex scenarios, such as a mail server hosting multiple mail accounts (or even hundreds of thousands) of domain names.

(Note that this type of Setup requires a DNS server, which is not covered in this article), but you can set up a DNS server by referencing the following article:

    • Configuring a cache-only DNS server on Centos/rhel 07

Finally, I strongly recommend that you familiarize yourself with the Postfix configuration file (MAIN.CF) and the Help manual for this program. If you have any questions, don't hesitate to use the comment box below or our forum linuxsay.com to tell us that you will get almost timely help from Linux gurus around the world.

RHCE Series (ix): How to use no client configuration Postfix

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.