電子郵件系統 電子郵件系統是我們在日常工作、生活中最常用的一種網路服務。 部署基礎的電子郵件系統 配置Postfix服務程式 Postfix是一款由IBM資助研發的免費開源電子郵件服務程式,能夠很好地相容Sendmail服務程式,可以方便Sendmail用戶遷移到Postfix服務上. 參數 | 作 ...
電子郵件系統
電子郵件系統是我們在日常工作、生活中最常用的一種網路服務。
部署基礎的電子郵件系統
[root@qdlinux ~]# yum install bind-chroot -y
[root@qdlinux ~]# vim /etc/hostname
[root@qdlinux ~]# hostname
mail.linuxprobe.com
//清空iptables防火牆預設策略,並保存策略狀態
[root@qdlinux ~]# iptables -F
[root@qdlinux ~]# service iptables save
iptables: Saving firewall rules to /etc/sysconfig/iptables:[ 確定 ]
[root@qdlinux ~]# vim /etc/named.conf
options {
listen-on port 53 { any; };
listen-on-v6 port 53 { ::1; };
directory "/var/named";
dump-file "/var/named/data/cache_dump.db";
statistics-file "/var/named/data/named_stats.txt";
memstatistics-file "/var/named/data/named_mem_stats.txt";
allow-query { any; };
[root@qdlinux ~]# vim /etc/named.rfc1912.zones
zone "linuxprobe.com" IN {
type master;
file "linuxprobe.com.zone";
allow-update { none; };
};
// cd /var/named
[root@qdlinux named]# cp -a named.localhost linuxprobe.com.zone
[root@qdlinux named]# vim linuxprobe.com.zone
$TTL 1D
@ IN SOA linuxprobe.com. root.linuxprobe.com. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS ns.linuxprobe.com.
ns IN A 192.168.56.25
@ IN MX 10 mail.linuxprobe.com.
mail IN A 192.168.56.25
[root@qdlinux named]# systemctl restart named
[root@qdlinux named]# systemctl enable named
ln -s '/usr/lib/systemd/system/named.service' '/etc/systemd/system/multi-user.target.wants/named.service'
配置Postfix服務程式
Postfix是一款由IBM資助研發的免費開源電子郵件服務程式,能夠很好地相容Sendmail服務程式,可以方便Sendmail用戶遷移到Postfix服務上.
參數 | 作用 |
---|---|
myhostname | 郵局系統的主機名 |
mydomain | 郵局系統的功能變數名稱 |
myorigin | 從本機發出的郵件的功能變數名稱名稱 |
inet_interfaces | 監聽的網卡介面 |
mydestination | 可接受郵件的主機名或功能變數名稱 |
mynetworks | 設置可轉發哪些主機的郵件 |
relay_domains | 設置可轉發哪些網域的郵件 |
[root@qdlinux named]# yum install postfix
[root@qdlinux named]# vim /etc/postfix/main.cf
77 myhostname = mail.linuxprobe.com
84 mydomain = linuxprobe.com
100 myorgin = $mydomain
117 inet_interfaces = all
165 mydestination = $myhostname, $mydomain
//添加本地用戶創建密碼用於電子郵件系統登錄賬戶
[root@mail named]# systemctl restart postfix.service
[root@mail named]# systemctl enable postfix
配置Dovecot服務程式
[root@mail named]# yum install dovecot -y
[root@mail named]# vim /etc/dovecot/dovecot.conf
25 protocols = imap pop3 lmtp
26 disable_plaintext_auth = no
51 login_trusted_networks = 192.168.56.0/24
[root@mail named]# vim /etc/dovecot/conf.d/10-mail.conf
24 # mail_location = maildir:~/Maildir
25 # mail_location = mbox:~/mail:INBOX=/var/mail/%u
26 mail_location = mbox:~/mail:INBOX=/var/mail/%u
[root@mail named]# su - wgzll
上一次登錄:二 8月 21 08:52:59 CST 2018:0 上
ABRT has detected 1 problem(s). For more info run: abrt-cli list --since 1534813209
[wgzll@mail ~]$ id
uid=1000(wgzll) gid=1000(wgzll) 組=1000(wgzll),10(wheel) 環境=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
[wgzll@mail ~]$ mkdir -p mail/.imap/INBOX
[root@mail named]# systemctl restart dovecot
[root@mail named]# systemctl enable dovecot
ln -s '/usr/lib/systemd/system/dovecot.service' '/etc/systemd/system/multi-user.target.wants/dovecot.service'
[root@mail named]# systemctl restart postfix.service
[root@mail named]# systemctl enable postfix
測試電子郵件系統
主機名稱 | 操作系統 | IP地址 |
---|---|---|
電子郵件系統及DNS伺服器 | RHEL7 | 192.168.56.25 |
客戶端主機 | Windows 7 | 192.168.56.30 |
[root@mail named]# mail
Heirloom Mail version 12.5 7/5/10. Type ? for help.
"/var/spool/mail/root": 2 messages 2 new
>N 1 [email protected] Tue Aug 21 09:20 170/6951 "[abrt] full crash report"
N 2 wgzll Sat Aug 25 20:38 119/3662 "Hello~"
& 2
Message 2:
From [email protected] Sat Aug 25 20:38:05 2018
Return-Path: <[email protected]>
X-Original-To: [email protected]
Delivered-To: [email protected]
From: "wgzll" <[email protected]>
To: <[email protected]>
Subject: Hello~
Date: Sat, 25 Aug 2018 20:38:06 +0800
Content-Type: multipart/alternative;
boundary="----=_NextPart_000_0001_01D43CB3.872C58B0"
X-Mailer: Microsoft Office Outlook 12.0
Thread-Index: AdQ8cHcGmIa/AAncTiqrA9WpZ+Lqew==
Content-Language: zh-cn
x-cr-hashedpuzzle: oeE= 5hM= ALkx CcEg CvVx EJgt EYbg GBXk GQ56 GSqZ GnVQ Ig73 JIgR Jbgs J
9/E KqFk;1;cgBvAG8AdABAAGwAaQBuAHUAeABwAHIAbwBiAGUALgBjAG8AbQA=;Sosha1_v1;7;{B434BAF0-D9B5
-4FEF-8935-91553750D981};dwBnAHoAbABsAEAAbABpAG4AdQB4AHAAcgBvAGIAZQAuAGMAbwBtAA==;Sat, 25
Aug 2018 12:38:03 GMT;SABlAGwAbABvAH4A
x-cr-puzzleid: {B434BAF0-D9B5-4FEF-8935-91553750D981}
Status: R
Content-Type: text/plain;
charset="gb2312"
當您收到這封郵件時,證明我的郵局系統試驗已經成功!
& quit
Held 2 messages in /var/spool/mail/root
您在 /var/spool/mail/root 中有郵件
設置用戶別名信箱
[root@mail named]# cat /etc/aliases
#
# Aliases in this file will NOT be expanded in the header from
# Mail, but WILL be visible over networks or from /bin/mail.
#
# >>>>>>>>>> The program "newaliases" must be run after
# >> NOTE >> this file is updated for any changes to
# >>>>>>>>>> show through to sendmail.
#
# Basic system aliases -- these MUST be present.
mailer-daemon: postmaster
postmaster: root
# General redirections for pseudo accounts.
bin: root
daemon: root
adm: root
lp: root
sync: root
shutdown: root
halt: root
mail: root
news: root
uucp: root
operator: root
games: root
gopher: root
ftp: root
nobody: root
radiusd: root
nut: root
dbus: root
vcsa: root
canna: root
wnn: root
rpm: root
nscd: root
pcap: root
apache: root
webalizer: root
dovecot: root
fax: root
quagga: root
radvd: root
pvm: root
amandabackup: root
privoxy: root
ident: root
named: root
xfs: root
gdm: root
mailnull: root
postgres: root
sshd: root
smmsp: root
postfix: root
netdump: root
ldap: root
squid: root
ntp: root
mysql: root
desktop: root
rpcuser: root
rpc: root
nfsnobody: root
ingres: root
system: root
toor: root
manager: root
dumper: root
abuse: root
newsadm: news
newsadmin: news
usenet: news
ftpadm: ftp
ftpadmin: ftp
ftp-adm: ftp
ftp-admin: ftp
www: webmaster
webmaster: root
noc: root
security: root
hostmaster: root
info: postmaster
marketing: postmaster
sales: postmaster
support: postmaster
# trap decode to catch security attacks
decode: root
# Person who should get root's mail
#root: marc
------------------------------------------------------------------------
------------------------------------------------------------------------
[root@mail named]# mail
Heirloom Mail version 12.5 7/5/10. Type ? for help.
"/var/spool/mail/root": 3 messages 1 new 2 unread
U 1 [email protected] Tue Aug 21 09:20 171/6961 "[abrt] full crash report"
2 wgzll Sat Aug 25 20:38 120/3673 "Hello~"
>N 3 wgzll Sat Aug 25 21:06 118/3583 "你好,用戶Bin"
& 3
Message 3:
From [email protected] Sat Aug 25 21:06:18 2018
Return-Path: <[email protected]>
X-Original-To: [email protected]
Delivered-To: [email protected]
From: "wgzll" <[email protected]>
To: <[email protected]>
Subject: 你好,用戶Bin
Date: Sat, 25 Aug 2018 21:06:19 +0800
Content-Type: multipart/alternative;
boundary="----=_NextPart_000_0006_01D43CB7.783380F0"
X-Mailer: Microsoft Office Outlook 12.0
Thread-Index: AdQ8dGhJfCWNrEMJQdynqCBhnZ8rHQ==
Content-Language: zh-cn
x-cr-hashedpuzzle: hBM= CDJ0 CMXa CxHz DMZJ Eusa FJ2V GSHH GqwB GvwW I7Kc I8yv JPcS J+7K K
Qci KTEA;1;YgBpAG4AQABsAGkAbgB1AHgAcAByAG8AYgBlAC4AYwBvAG0A;Sosha1_v1;7;{FEA2CB4E-66DB-46A
6-B45B-893EBA119A6F};dwBnAHoAbABsAEAAbABpAG4AdQB4AHAAcgBvAGIAZQAuAGMAbwBtAA==;Sat, 25 Aug
2018 13:06:16 GMT;YE99WSwAKHU3YkIAaQBuAA==
x-cr-puzzleid: {FEA2CB4E-66DB-46A6-B45B-893EBA119A6F}
Status: R
Content-Type: text/plain;
charset="gb2312"
這是一封發給用戶Bin的文件.
& quit
Held 3 messages in /var/spool/mail/root
您在 /var/spool/mail/root 中有郵件
[root@mail named]# mail [email protected]
Subject: 你好,wgzll
你好,這是一封測試郵件!!!
.
EOT