Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to install and deploy Postfix under Linux

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "how to install and deploy Postfix under Linux". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let Xiaobian take you to learn "How to install and deploy Postfix under Linux"!

Deploying DNS servers

postfix Make an MX record based on domain name and address, A record, PTR record (Generally, mail servers on the Internet need to reverse the solution, no PTR record will be considered spam)

$ service iptables stop$ chkconfig iptables on$ setenforce 0$ hostname mail.ywnds.com$ echo "127.0.0.1 mail.ywnds.com" >> /etc/hosts$ yum install bind bind-utils bind-libs

configure DNS

$ cat /etc/named.confoptions { listen-on port 53 { any; }; directory "/var/named"; allow-query { any; }; recursion yes;{zone "ywnds.com" IN { type master; file "ywnds.com";};#include "/etc/named.root.key";

PS: Add and modify the above content.

$ cat /var/named/ywnds.com$TTL 1D@ IN SOA ns.ywnds.com. root.ywnds.com. ( 0 ; serial 1D ; refresh 1H ; retry 1W ; expire 3H ) ; minimum@ IN NS nsns IN A 192.168.60.10@ IN MX 10 smtpsmtp IN A 192.168.60.10pop3 IN A 192.168.60.10mail IN A 192.168.60.10 $ service named restart$ chkeconfig named onpostfix main profile Add the following

The postfix master configuration file is modularized, where:

/etc/postfix/main.cf: This file holds global configuration information that is used by all processes unless it is reset in the master.cf file./ etc/postfix/master.cf: This file holds additional process runtime environment parameters, and the configuration defined in main.cf may be overwritten by the configuration in this file.

All parameters in the configuration file must be written at the top or they will be treated as a continuation of the previous line. In addition, most of the postfix configuration files have been defaulted, and can be viewed using postconf -d.

$cat /etc/postfix/main.cfinet_protocols = allinet_interfaces = 192.168.60.10,127.0.0.1myhostname = mail.ywnds.commydomain = ywnds.commyorigin = $mydomainmydestination = $myhostname, localhost.$ mydomain, localhost, $mydomainmynetworks = 127.0.0.0/8message_size_limit = 20485760mailbox_size_limit = 5097152000show_user_unknown_table_name = nobounce_queue_lifetime = 1dmaximal_queue_lifetime = 1dhome_mailbox = Maildir/#home_mailbox = Mailbox#mailbox_command = /some/where/procmail

Parameter explanation:

inet_protocols = all#Specifies the protocol. inet_interfaces = 192.168.60.10Specifies the network interface on which the postfix system listens. myhostname = mail.ywnds.com #Specify the hostname. mydomain = ywnds.com #Specifies the domain name, postfix removes the first part of myhostname by default and uses mydomain as the value. myorigin = $mydomain#Used to automatically complete the domain user, used to indicate the domain name where the sender is located, that is, to disguise the sending address. mydestination = $myhostname, localhost.$ mydomain, localhost,$mydomain#This defines the recipient domain name of Postfix when receiving emails, that is, which domain names Postfix will receive emails from. Anything not in this domain is considered a relay email. If you do not add $mydomain, you are not allowed to receive emails from this domain. mynetworks = 127.0.0.0/8#Relay according to network address. By default, relay is given to the whole network where you are located. The postfix system distinguishes whether the user is remote or local according to its value. Here, it is set to relay only to the local computer. message_size_limit = 20485760mailbox_size_limit = 5097152000show_user_unknown_table_name = no#Message size limit is 20 megabytes, mailbox size limit is 5 gigabytes. bounce_queue_lifetime = 1dmaximal_queue_lifetime = 1d#Queue timeout is limited to 1 day. home_mailbox = Maildir/home_mailbox = Mailbox

#There are two mailbox delivery methods: one is Mailbox mode, that is, all the mail contents of the same user are stored as a single file, usually stored in the/var/spool/mail/directory with the same file name as the user name (Postfix default); the second is Maildir mode, that is, using directory structure to store the user's mail contents. Each user uses a folder, and each mail is stored as an independent file. Maildir is faster and more efficient for managing email content pages.

mailbox_command = /some/where/procmail

#MDA can be configured to use procmail (postfix default delivery agent).

attention problems

1. In the postfix configuration file, parameter lines and comment lines cannot be in the same line;

The value of any parameter does not need to be quoted, otherwise, the quotation marks will be used as part of the parameter value;

3. Perform postfix reload after modifying parameters and their values to make them take effect; however, if inet_interfaces are modified, you need to restart postfix;

4, if a parameter has multiple values, you can put them in different lines, just need to put a space before each line after it;postfix will regard the text line with the first character as a space or tab as a continuation of the previous line;

SMTP protocol sending mail command Postfix mail sending configuration in Linux (3) Postfix mail sending configuration in Linux (3) SMTP status code: 1xx: pure information 2xx: correct 3xx: previous operation has not been completed, need to continue to supplement 4xx: temporary error 5xx: permanent error

SMTP protocol is simple enough to allow any user to send mail and to send it to anyone. Where MAIL FROM can be arbitrarily specified address. However, the recipient (RCPT TO) can be sent to users in the domain or relayed to users in other domains. Such as 163 or QQ mailbox. However, in general, public network mailboxes need to be resolved in reverse. If they can be resolved, they will receive emails. If they cannot be resolved, they will lose emails. If full resolution is a bit too harsh, you can also resolve some domain names. If you don't believe me, you can change the sender to xxx@taobao.com and try whether your recipient can still receive the email. (If you enter the wrong message, you can press Ctrl + Backspace)

Postfix allows relaying by default on this machine and all hosts on this machine's network, so you can send mail to other domains. But since we used the command "mynetworks = 127.0.0.0/8" above, it means to relay only to the local machine. So other hosts are unable to send mail to other domains, as shown below:

Postfix mail sending configuration in Linux (3) Postfix mail sending configuration in Linux (3)

Note: Although 127.0.0.1 and 192.168.60.10 can access this machine, they have different meanings. 127.0.0.1 is internal to the machine, while 192.168.60.10 is through the NIC. The requested URL/var/log/maillog/was not found on this server.

Create two mailboxes to test the user and give the password (password is also the same as the username)$ useradd -s /sbin/nologin openstack$ useradd -s /sbin/nologin hadoop mail alias

Mail aliases can transfer mail sent to one user to another user. You can define user aliases in the/etc/aliases file as follows:

Openstack: root

All messages sent to Openstack users are sent to root. But Postfix will not use this file because it is too slow to retrieve in text files, so it needs to be converted to another format by hash encoding/etc/aliases.db (postfix supports hash format), and the new aliases command can be used to transcode between them. Execute the command new aliases directly.

mail queue

Postfix maintains two queues: the pending mails queue and the deferred mail queue. The waiting queue contains emails that have failed to be sent temporarily and need to be resend. Postfix will resend periodically (default 5 minutes, customizable).

Postfix maintains five queues:

Input queue, the first stop of messages entering Postfix system; active queue, qmgr Move incoming queue messages to active queue; Wait queue, hold messages that cannot be sent temporarily; Failure queue, hold damaged or unreadable messages; Retention queue, keep messages in Postfix queue system indefinitely; List message queue $ postqueue -p Delete all queue messages $ postsuper -d ALL deferred Delete all messages stsuper -d ALL

PS: You can also use tail /var/log/maillog to view the message queue log information when sending an email. For example,"status=sent" means that the email was sent successfully, and "status=deferred" means that the email is waiting in the queue.

At this point, I believe that everyone has a deeper understanding of "how to install and deploy Postfix under Linux", so let's actually operate it! Here is the website, more related content can enter the relevant channels for inquiry, pay attention to us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report