Configuration and use of Postfix under Linux

Source: Internet
Author: User
Tags nameserver

The postfix was created to replace the traditional sendmail. Compared to Sendmail,postfix in speed, performance and stability are better. Now a lot of mainstream mail service is actually using Postfix. Postfix is an option when we need a lightweight mail server.

1. Postfix is free of charge:
Postfix wants to function in a wide range of Internet users, trying to influence most e-mail systems on the Internet, so it is free.
2. Faster:
Postfix is about three times times faster than SendMail in performance. A desktop PC running Postfix can send and receive millions of e-mails per day.
3. Good compatibility:
The postfix is sendmail compatible, allowing SendMail users to easily migrate to postfix. Postfix supports/var[/spool]/mail,/etc/aliases, NIS, and ~/.forward files.
4. More robust:
The postfix is designed to work properly under heavy loads. When the system is running out of available memory or disk space, Postfix automatically reduces the number of running processes. When the number of messages processed increases, the process that Postfix runs does not follow.
5. More flexible:
Postfix is made up of more than a dozen small programs, each of which completes a specific function. You can
Set the run parameters for each program through the configuration file.
6. Security
The postfix has a multi-layered defense structure that can be used to effectively protect against malicious intruders. For example, most postfix programs can run under lower permissions, cannot access security-related local delivery programs over the network, and so on.

Here's how to build and configure the Postfix service on Linux:


1. To switch off all services related to SendMail, it is best to uninstall SendMail directly.

# Service SendMail Stop
# chkconfig SendMail off

#rpm-qa | grep SendMail | Xargs rpm-e


2. Install the postfix.

redhat6.0 the above version should be the default integration of the Postfix service, if not installed, can be installed manually.

Rpm-qa | grep postifx (see if it's installed)

Yum install Postfix


3. After the installation is complete, modify the configuration file:/etc/postfix/main.cfg


Vi/etc/postfix/main.cf


Myhostname = sample.test.com← Sets the hostname of the system


MyDomain = test.com← Set the domain name (we will let this be set to be the part after the e-mail address "@")


Myorigin = $mydomain ← Set the part after the address "@" to the domain name (not the system host name)


Inet_interfaces = all← Accept requests from all networks


mydestination = $myhostname, localhost. $mydomain, localhost, $mydomain ← Specify the domain name to send to local mail


Home_mailbox = maildir/← Specify user mailbox Directory


< save exit! >


4. Add DNS server for this machine.

Why is DNS Server? Because in the mail sending process, need to address the domain address of the e-mail to the IP address, and then sent to the corresponding recipient, here is related to the DNS of a record and MX records relevant knowledge, unfamiliar classmates can Google or Baidu brain repair:-)


How do I add DNS server, where does DNS server go looking?

Vim/etc/resolv.conf

Add the following line:

NameServer 8.8.8.8

NameServer 8.8.4.4


The above 8.8.8.8/8.8.4.4 is Google free DNS server, of course, there are a lot of complimentary DNS server for everyone to use, you can Google a bit:-)


5. Test whether the message can be sent successfully:

Command line Input $: > echo "Mail Content" | mail-s "Mail Subject" [email protected]


Note: if you see below warings after you run above command.

send-mail: warning: inet_protocols: ipv6 support is disabled: address  family not supported by protocolsend-mail: warning: inet_protocols:  Configuring for ipv4 support onlypostdrop: warning: inet_protocols: ipv6  support is disabled: Address family not supported by  protocolpostdrop: warning: inet_protocols: configuring for ipv4 support  Only 

That means you don ' t has IPv6 configured in your OS ' s network stack, but your mailer (presumably postfix) is configured T o use IPv6. Since there is no IPv6 for your mailer to use, it's warning you it's only going to use IPV4.

to Disable the Waring messsage, go to /ETC/POSTFIX/MAIN.CF  and change from:

Inet_protocols = All

To:

Inet_protocols = IPv4

This would only use IPv4 and the warning message would go away.

You'll have an issue a stop and start for Postfix to register of the change.

Service Postfix Restart


6. Check log to confirm email status:

The log location of the postfix message is:/var/log/maillog

If sent successfully, will return 250 and OK, also can go to own mail client to check.


Everything OK, that postfix Mail Service should be built successfully.


&&&&&&&&&&&&&&&&&&&&&& &&&&&&&&&&&&&&&&&&&&&& &&&&&&&&&&&&&&&&&&&&&& &&&&&&&&&&&&&&&

Other useful postfix maintenance commands, one-time routine inspection and maintenance:

MAILQ : Lists all messages that are currently in the Postfix send queue

postsuper-dAll: Deletes all messages that are currently waiting to be sent, including sending a failed return letter

Of course, there are many, do not list, we can search online extension,good luck!


7.Update Mail from Sender


echo "[email protected] [email protected]" >>/etc/postfix/generic echo "smtp_generic_maps = Hash:/etc/postfix/gen Eric ">>/ETC/POSTFIX/MAIN.CF postmap/etc/postfix/genericservice postfix restart


Configuration and use of Postfix under Linux

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.