Problems encountered during installation
Question 1:
[root@lotus postfix-2.11.11]# make makefiles 'CCARGS=-DHAS_MYSQL -I/usr/include/mysql -DUSE_SASL_AUTH -DUSE_CYRUS_SASL -I /usr/include/sasl -DUSE_TLS ' 'AUXLIBS=-L/usr/lib64/mysql -lmysqlclient -lz -lm -L/usr/lib64/sasl2 -lsasl2 -lssl -lcrypto' make -f Makefile.in MAKELEVEL= Makefiles (echo "# Do not edit -- this file documents how Postfix was built for your machine."; /bin/sh makedefs) >makedefs.tmp No <db.h> include file found. Install the appropriate db*-devel package first. make: *** [Makefiles] Error 1 make: *** [makefiles] Error 2
resolvent
[root@lotus postfix-3.1.15]# yum install db4-devel -y
report errors:
postfix/postfix-script: warning: not set-gid or not owner+group+world executable: /usr/sbin/postqueue
postfix/postfix-script: warning: not set-gid or not owner+group+world executable: /usr/sbin/postdrop
resolvent:
[root@lotus ~]# chmod g+s /usr/sbin/postqueue [root@lotus ~]# chmod g+s /usr/sbin/postdrop
Introduction to basic information of e-mail
SMTP(Simpe Mail Transfer Protocol) Simple Mail Transfer Protocol
POP3(Post Office Protocol)
IMAP4(Internet Mail Access Protocol)
Uucp (UNIX to UNIX copy) the protocol for UNIX hosts to copy files
SMTP(25/tcp)
Each server has a directory to store mail, and each user's mail is a file named after the user name
The email that the user sees will be saved to the user's home directory mbox
Mail Transfer: the process of MT(Mail Transfer) sending mail from the sender to the mail host of the other host
Mail delivery: the process of sending MD(Mail Delivery) from the host to the user's mailbox
Mail user: MU(Mail User)
Mail user agent: MUA(Mail User Agent)
LMTP(local Mail Transfer Protocol)
Mail transfer agent: MTA(Mail Transfer Agent)
After the user writes the mail, it is delivered to the local mail server through SMTP protocol. The mail server judges whether it is the mail of the local user through MTA. If it is the local user, it is directly put into the user's mailbox through lmtp. If it is the remote user, it is sent to the remote user's mail server through SMTP protocol.
Mail delivery agent: MDA(Mail Delivery Agent) when the mail arrives at the remote user mail server, the mail server will call MDA for mail delivery
How to view the mail: get the mail from the mailbox through MUA(Mail User Agent) and save it to the user's home directory
SASL(Simple Authentication Secure Layer): complete mail user authentication
MRA(Mail Retrieval Agent) mail retrieval agent – POP3 or IMAP, which is retrieved from the mailbox and delivered to the user
WebMail
LDAP(LightWeight Directory Access Protocol) Lightweight Directory Access Protocol: fast reading speed and slow writing speed
Common mail server and client software
MTA:
sendmail: single structure, SUID, complex syntax of configuration file (written in m4)
qmail:
postfix: modular design, safe, compatible with sendmail and high efficiency
exim:
exchange: for window, asynchronous message collaboration platform
MDA:
procmail:
maildrop:
MRA(pop3,imap4):
cyrus-imap
dovecot
MUA:
Outlook Express,Outlook
Foxmail
ThunderBird
Evolution
Mutt (text interface)
WebMail:
Openwebmail
Squirrelmail
ExtMail(Extman)
SASL:
cyrus-sasl
courier-authlib
Compile and install postfix
- Add users postfix and postprop
[root@lotus postfix-3.1.15]# groupadd -g 2526 postdrop [root@lotus postfix-3.1.15]# useradd -g postdrop -u 2526 -s /sbin/nologin -M postdrop [root@lotus postfix-3.1.15]# groupadd -g 2525 postfix [root@lotus postfix-3.1.15]# useradd -g postfix -u 2525 -s /sbin/nologin -M postfix
- Download postfix postfix , and install postfix
[root@lotus ~]# tar xf postfix-2.11.11.tar.gz [root@lotus ~]# cd postfix-2.11.11 #DHAS_MYSQL: mysql header file #DUSE_CYRUS_SASL: SASL header file #-DUSE_TLS: support SMTP based SSL #-DUSE_SASL_AUTH: support SASL certification #AUXLIBS: library files #-lz: compress library files #-lm: module library file #-lsasl2: library file of sasl2 #-lssl: ssl library file #-lcrypto: encryption library file #Note: the header file and library file are determined according to the directory of the installation program. The directory of compilation installation and rpm installation may be different [root@lotus postfix-2.11.11]# make makefiles 'CCARGS=-DHAS_MYSQL -I/usr/include/mysql -DUSE_SASL_AUTH -DUSE_CYRUS_SASL -I /usr/include/sasl -DUSE_TLS ' 'AUXLIBS=-L/usr/lib64/mysql -lmysqlclient -lz -lm -L/usr/lib64/sasl2 -lsasl2 -lssl -lcrypto' [root@lotus postfix-2.11.11]# make [root@lotus postfix-2.11.11]# make install /bin/sh postfix-install Warning: if you use this script to install Postfix locally, this script will replace existing sendmail or Postfix programs. Make backups if you want to be able to recover. Before installing files, this script prompts you for some definitions. Most definitions will be remembered, so you have to specify them only once. All definitions should have a reasonable default value. Please specify the prefix for installed file names. Specify this ONLY if you are building ready-to-install packages for distribution to OTHER machines. See PACKAGE_README for instructions. install_root: [/] / Please specify a directory for scratch files while installing Postfix. You must have write permission in this directory. tempdir: [/root/postfix-2.11.11] /tmp/postfix Please specify the final destination directory for installed Postfix configuration files. config_directory: [/etc/postfix] /etc/postfix Please specify the final destination directory for installed Postfix administrative commands. This directory should be in the command search path of adminstrative users. command_directory: [/usr/sbin] /usr/sbin Please specify the final destination directory for installed Postfix daemon programs. This directory should not be in the command search path of any users. daemon_directory: [/usr/libexec/postfix] /usr/libexec/postfix Please specify the final destination directory for Postfix-writable data files such as caches or random numbers. This directory should not be shared with non-Postfix software. data_directory: [/var/lib/postfix] Please specify the final destination directory for the Postfix HTML files. Specify "no" if you do not want to install these files. html_directory: [no] /www/postfix Please specify the owner of the Postfix queue. Specify an account with numerical user ID and group ID values that are not used by any other accounts on the system. mail_owner: [postfix] Please specify the final destination pathname for the installed Postfix mailq command. This is the Sendmail-compatible mail queue listing command. mailq_path: [/usr/bin/mailq] Please specify the final destination directory for the Postfix on-line manual pages. You can no longer specify "no" here. manpage_directory: [/usr/local/man] Please specify the final destination pathname for the installed Postfix newaliases command. This is the Sendmail-compatible command to build alias databases for the Postfix local delivery agent. newaliases_path: [/usr/bin/newaliases] Please specify the final destination directory for Postfix queues. queue_directory: [/var/spool/postfix] Please specify the final destination directory for the Postfix README files. Specify "no" if you do not want to install these files. readme_directory: [no] Please specify the final destination pathname for the installed Postfix sendmail command. This is the Sendmail-compatible mail posting interface. sendmail_path: [/usr/sbin/sendmail]
- The startup information of postfix is in the / var/log/maillog file
[root@lotus ~]# tail /var/log/maillog Apr 18 00:25:02 lotus postfix/postfix-script[27300]: stopping the Postfix mail system Apr 18 00:25:02 lotus postfix/master[27280]: terminating on signal 15 Apr 18 00:25:05 lotus postfix/postfix-script[27351]: warning: not owned by root: /var/spool/postfix Apr 18 00:25:05 lotus postfix/postfix-script[27355]: warning: not owned by root: /var/spool/postfix/pid Apr 18 00:25:05 lotus postfix/postfix-script[27374]: starting the Postfix mail system Apr 18 00:25:05 lotus postfix/master[27376]: daemon started -- version 2.11.11, configuration /etc/postfix Apr 18 00:26:42 lotus postfix/postfix-script[27387]: stopping the Postfix mail system Apr 18 00:26:42 lotus postfix/master[27376]: terminating on signal 15 Apr 18 00:26:45 lotus postfix/postfix-script[27459]: starting the Postfix mail system Apr 18 00:26:45 lotus postfix/master[27461]: daemon started -- version 2.11.11, configuration /etc/postfix
-
Configuration file for postfix
postfix modularity
master: /etc/postfix/master.cf
pickup: picking process
Cleanup: cleanup process
qmgr: queue manager
defer: delay send queue manager
rewrite: rewrite
verify: verifier
flush: cleanermain: /etc/postfix/main.cf parameter = Note: the parameter must be top grid(Absolute line beginning)To write,A line that begins with a blank character is considered a continuation of the previous line
postconf: configure postfix
-d: Displays the default configuration
-n: Displays the modified configuration
-m: Supported lookup table types
-A: Displays the supported SASL client plug-in types
-e parameter=value: change the configuration information of a parameter and save it to main CF file
[root@lotus ~]# postconf -m btree cidr environ fail hash internal memcache mysql nis pcre proxy regexp socketmap static tcp texthash unix [root@lotus ~]# postconf -A cyrus
Sending mail from smtp client to smtp server:
- Since smtp service is based on TCP/IP protocol, three handshakes of TCP/IP are required first
- After the handshake is successful, the client sends hello to the server. After receiving the connection request from the client, the server sends back the confirmation information
- After receiving the confirmation information from the server, the client sends the sender information (mail from) to the smtp server, and the server sends back the confirmation information, indicating that the sender information has been received
- The client then sends the recipient information (rcpt to) to the server, and the server sends back the confirmation information after receiving it
- Then, the client sends the text information to the server with [.] The end indicates that the text has ended
- At this point, the server begins to deliver mail.
smtp status code:
1xx: pure information
2xx: correct
3xx: the previous operation has not been completed, and it needs to be supplemented
4xx: temporary error
5xx: permanent error
smtp protocol command:
helo(smtp protocol)
mail from:
rcpt to: recipient
#Test email sending through telnet [root@lotus ~]# telnet localhost 25 Trying ::1... telnet: connect to address ::1: Connection refused Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. 220 lotus.tye ESMTP Postfix helo localhost 250 lotus.tye mail from:root@tye.com 250 2.1.0 Ok rcpt to:root 250 2.1.5 Ok data 354 End data with <CR><LF>.<CR><LF> subject:How are you these days? Are you gua le ma [.]#This point is very important to mark the end of the mail 250 2.0.0 Ok: queued as 3B7E2BF2B7 #View mail log [root@lotus ~]# tail /var/log/maillog Apr 18 07:06:19 lotus postfix/postfix-script[2181]: starting the Postfix mail system Apr 18 07:06:19 lotus postfix/master[2183]: daemon started -- version 2.11.11, configuration /etc/postfix Apr 18 07:06:26 lotus postfix/smtpd[2187]: warning: dict_nis_init: NIS domain name not set - NIS lookups disabled Apr 18 07:06:26 lotus postfix/smtpd[2187]: connect from localhost[127.0.0.1] Apr 18 07:06:51 lotus postfix/smtpd[2187]: 3B7E2BF2B7: client=localhost[127.0.0.1] Apr 18 07:09:28 lotus postfix/cleanup[2190]: 3B7E2BF2B7: message-id=<20210417230651.3B7E2BF2B7@lotus.tye> Apr 18 07:09:28 lotus postfix/qmgr[2185]: 3B7E2BF2B7: from=<root@tye.com>, size=347, nrcpt=1 (queue active) Apr 18 07:09:29 lotus postfix/local[2192]: warning: dict_nis_init: NIS domain name not set - NIS lookups disabled Apr 18 07:09:29 lotus postfix/local[2192]: 3B7E2BF2B7: to=<root@lotus.tye>, orig_to=<root>, relay=local, delay=164, delays=164/0.29/0/0, dsn=2.0.0, status=sent (delivered to mailbox) Apr 18 07:09:29 lotus postfix/qmgr[2185]: 3B7E2BF2B7: removed You have mail in /var/spool/mail/root #View message content [root@lotus ~]# mail Heirloom Mail version 12.4 7/29/08. Type ? for help. "/var/spool/mail/root": 1 message 1 new >N 1 root@tye.com Sun Apr 18 07:09 20/454 "How are you these days?" & 1 Message 1: From root@tye.com Sun Apr 18 07:09:29 2021 Return-Path: <root@tye.com> X-Original-To: root Delivered-To: root@lotus.tye subject:How are you these days? Date: Sun, 18 Apr 2021 07:06:44 +0800 (CST) From: root@tye.com Status: R Are you gua le ma.
By default, postfix identifies the network segment where the local IP address is located as the local network and relays mail for it.