[研究]Postfix 3.5.9郵件伺服器 (Mail Server) 安裝 (CentOS/Rocky Linux 9.1)
2023-04-12
官方網站:https://www.postfix.org/
Postfix Documentation:https://www.postfix.org/documentation.html
sudo yum -y update (非必須)
sudo yum -y install postfix
sudo systemctl start postfix
sudo postfix set-permissions
sudo postfix check
sudo systemctl status postfix
實際過程
[user1@localhost ~]$ sudo yum -y install postfix We trust you have received the usual lecture from the local System Administrator. It usually boils down to these three things: #1) Respect the privacy of others. #2) Think before you type. #3) With great power comes great responsibility. [sudo] password for user1: Rocky Linux 9 - BaseOS 1.1 MB/s | 1.8 MB 00:01 Rocky Linux 9 - AppStream 1.1 MB/s | 6.6 MB 00:05 Rocky Linux 9 - Extras 7.5 kB/s | 8.7 kB 00:01 Dependencies resolved. ================================================================================ Package Architecture Version Repository Size ================================================================================ Installing: postfix x86_64 2:3.5.9-19.el9 appstream 1.4 M Transaction Summary ================================================================================ Install 1 Package Total download size: 1.4 M Installed size: 4.4 M Downloading Packages: postfix-3.5.9-19.el9.x86_64.rpm 3.1 MB/s | 1.4 MB 00:00 -------------------------------------------------------------------------------- Total 956 kB/s | 1.4 MB 00:01 Rocky Linux 9 - AppStream 1.7 MB/s | 1.7 kB 00:00 Importing GPG key 0x350D275D: Userid : "Rocky Enterprise Software Foundation - Release key 2022 <releng@rockylinux.org>" Fingerprint: 21CB 256A E16F C54C 6E65 2949 702D 426D 350D 275D From : /etc/pki/rpm-gpg/RPM-GPG-KEY-Rocky-9 Key imported successfully Running transaction check Transaction check succeeded. Running transaction test Transaction test succeeded. Running transaction Preparing : 1/1 Running scriptlet: postfix-2:3.5.9-19.el9.x86_64 1/1 Installing : postfix-2:3.5.9-19.el9.x86_64 1/1 Running scriptlet: postfix-2:3.5.9-19.el9.x86_64 1/1 Verifying : postfix-2:3.5.9-19.el9.x86_64 1/1 Installed: postfix-2:3.5.9-19.el9.x86_64 Complete! [user1@localhost ~]$ sudo systemctl start postfix [user1@localhost ~]$ sudo systemctl enable postfix Created symlink /etc/systemd/system/multi-user.target.wants/postfix.service → /usr/lib/systemd/system/postfix.service. [user1@localhost ~]$ sudo systemctl status postfix ● postfix.service - Postfix Mail Transport Agent Loaded: loaded (/usr/lib/systemd/system/postfix.service; enabled; vendor p> Active: active (running) since Wed 2023-04-12 07:45:54 CST; 16s ago Main PID: 33345 (master) Tasks: 3 (limit: 22814) Memory: 4.9M CPU: 362ms CGroup: /system.slice/postfix.service ├─33345 /usr/libexec/postfix/master -w ├─33346 pickup -l -t unix -u └─33347 qmgr -l -t unix -u Apr 12 07:45:54 localhost.localdomain systemd[1]: Starting Postfix Mail Transpo> Apr 12 07:45:54 localhost.localdomain restorecon[33271]: /usr/sbin/restorecon: > Apr 12 07:45:54 localhost.localdomain postfix/master[33345]: daemon started -- > Apr 12 07:45:54 localhost.localdomain systemd[1]: Started Postfix Mail Transpor> [user1@localhost ~]$ [user1@localhost ~]$ sudo postfix set-permissions [user1@localhost ~]$ sudo postfix check [user1@localhost ~]$ sudo systemctl status postfix ● postfix.service - Postfix Mail Transport Agent Loaded: loaded (/usr/lib/systemd/system/postfix.service; enabled; vendor p> Active: active (running) since Wed 2023-04-12 07:45:54 CST; 2min 12s ago Main PID: 33345 (master) Tasks: 3 (limit: 22814) Memory: 4.9M CPU: 363ms CGroup: /system.slice/postfix.service ├─33345 /usr/libexec/postfix/master -w ├─33346 pickup -l -t unix -u └─33347 qmgr -l -t unix -u Apr 12 07:45:54 localhost.localdomain systemd[1]: Starting Postfix Mail Transpo> Apr 12 07:45:54 localhost.localdomain restorecon[33271]: /usr/sbin/restorecon: > Apr 12 07:45:54 localhost.localdomain postfix/master[33345]: daemon started -- > Apr 12 07:45:54 localhost.localdomain systemd[1]: Started Postfix Mail Transpor> [user1@localhost ~]$ |
如果Postfix正在運行,系統會顯示"Active (running)"的狀態。
Postfix 還有哪些相關套件
[user1@localhost ~]$ yum list | grep postfix postfix.x86_64 2:3.5.9-19.el9 @appstream pcp-pmda-postfix.x86_64 5.3.7-7.el9 appstream postfix-cdb.x86_64 2:3.5.9-19.el9 appstream postfix-ldap.x86_64 2:3.5.9-19.el9 appstream postfix-mysql.x86_64 2:3.5.9-19.el9 appstream postfix-pcre.x86_64 2:3.5.9-19.el9 appstream postfix-perl-scripts.x86_64 2:3.5.9-19.el9 appstream postfix-pgsql.x86_64 2:3.5.9-19.el9 appstream postfix-sqlite.x86_64 2:3.5.9-19.el9 appstream [user1@localhost ~]$ |
Postfix 相關程序
[user1@localhost ~]$ ps aux | grep postfix root 33345 0.0 0.1 38172 4500 ? Ss 07:45 0:00 /usr/libexec/postfix/master -w postfix 33346 0.0 0.2 45224 8216 ? S 07:45 0:00 pickup -l -t unix -u postfix 33347 0.0 0.2 45268 8316 ? S 07:45 0:00 qmgr -l -t unix -u user1 34034 0.0 0.0 221664 2212 pts/0 S+ 07:54 0:00 grep --color=auto postfix [user1@localhost ~]$ |
使用 postconf ( Postfix Configuration Utility ) 組態工具來檢查版本
[user1@localhost ~]$ postconf -d | grep mail_version mail_version = 3.5.9 milter_macro_v = $mail_name $mail_version [user1@localhost ~]$ |
********************************************************************************
設定相關資訊
Postfix Documentation:https://www.postfix.org/documentation.html
主要設定文件:/etc/postfix/main.cf
設置郵件域名:在main.cf文件中,您可以設置myhostname和mydomain選項,以指定Postfix伺服器使用的主機名和域名。例如:
myhostname = mail.example.com
mydomain = example.com
設置發送郵件的IP地址:如果您的伺服器有多個IP地址,您可以通過在main.cf文件中設置inet_interfaces選項,指定Postfix伺服器使用哪個IP地址發送郵件。例如:
inet_interfaces = 192.168.1.100
設置接收電子郵件的位置:在main.cf文件中,您可以設置mydestination選項,以指定Postfix郵件伺服器接收郵件的位置。例如:
mydestination = $myhostname, localhost.$mydomain, $mydomain
這個設置可以讓Postfix郵件伺服器接收來自自己主機名、本地主機和所在域的郵件。
設置SMTP服務器:在main.cf文件中,您可以設置smtpd_banner和smtpd_helo_required等選項,來定義SMTP服務器的欄位和要求的EHLO/HELO信息。例如:
smtpd_banner = $myhostname ESMTP
smtpd_helo_required = yes
設置郵件交換方式:在main.cf文件中,您可以設置relayhost和mynetworks等選項,來定義Postfix郵件伺服器的郵件交換方式。例如:
relayhost = smtp.example.com
mynetworks = 192.168.1.0/24, 127.0.0.0/8
這個設置可以讓Postfix郵件伺服器將郵件發送到指定的SMTP主機,並且指定了可以訪問此郵件伺服器的IP地址範圍。
這些是Postfix郵件伺服器的一些常用設置選項,您可以根據您的具體需求和環境進行進一步的設置。
********************************************************************************
(完)
沒有留言:
張貼留言