您好,登錄后才能下訂單哦!
################email#######
基本電子郵件發送
電子郵件發送
1 .服務器使用SMTP協議將電子郵件提交至TCP端口25,或由本地客戶端通過/usr/bin/sendmail程序進行提交。如果該MTA是最終目標位置,郵件將傳遞至MDA。否則,將使用MX記錄在DNS中查找下一個MTA,并使用SMTP進行轉發。
2 .MDA:“郵件發送代理”。MDA將郵件發送至收件人的本地郵件存儲位置(默認情況下是/var/spool/mail/user)。Postfix提供自己的MDA,以發送至基于文件的本地默認郵件存儲位置/usr/libexec/postfix/local.
3 .轉發:電子郵件服務器(MTA)將提交的郵件轉發至另一個服務器,以進行發送
4 .排隊:失敗的發送或轉發嘗試排隊等待,并由MTA定義重試。(默認情況下,Postfix每小時執行此操作一次)
5 .拒絕:在首次提交期間,電子郵件被電子郵件服務器拒絕
6 .退回:遠程服務器接受電子郵件以進行發送以后,又將該電子郵件退回給始發電子郵件服務器和/或用戶
7 .電子郵件以進行發送以后,又將該電子郵件退回給始發電子郵件服務器和/或用戶準備:
########################準備:#####
一: desktop虛擬機(westos-mail.westos.com)
#######配置網絡。yum源。修改主機名稱
88 cd /etc/sysconfig/network-scripts/
89 ls
90 vim ifcfg-eth0
DEVICE=eth0
ONBOOT=yes
BOOTPROTO=none
IPADDR=172.25.254.144
NETMASK=255.255.255.0
104 hostnamectl set-hostnamewestos-mail.westos.com
105 logout
107 vim /etc/yum.repos.d/rhel_dvd.repo
108 yum clean all
#####配置DNS
109 yum install bind -y
111 systemctl start named
114 vim /etc/named.conf
115 vim /etc/named.rfc1912.zones
116 cd /var/named
117 ls
118 cp -p named.localhostwestos.com.zone
119 vim westos.com.zone
120 cp -p westos.com.zoneqq.com.zone
121 vim qq.com.zone
122 systemctl restart named
131 systemctl stop firewalld
####測試:
123 vim /etc/resolv.conf
124 cd
126 dig dns.westos.com
136 dig -t mx westos.com
二:server虛擬機(qq-mail.qq.com)
######配置網絡。yum源。修改主機名稱
1 cd/etc/sysconfig/network-scripts/
2 ls
3 vim ifcfg-eth0
4 vim /etc/yum.repos.d/rhel_dvd.repo
5 yumclean all
6 hostnamectl set-hostname qq-mail.qq.com
7 logout
#######測試:
20 vim /etc/resolv.conf
21 dig dns.qq.com
22 dig -t mx qq.com
#######################
#### postfix ##########
1.
postfix提供smtp協議用來投遞郵件
默認端口25
/var/log/maillog ##服務日志
mail root@westos.com
Subject: hello
hello world
. #用"."來結束錄入內容并發送
mailq ##查看郵件隊列
postqueue -f ##重新處理郵件隊列
默認情況下郵件端口只在127.0.0.1上開啟
2.配置 兩個虛擬機都配置
可以在/etc/postfix/main.cf文件中找到以下所有指令。
(1)myorigin
重寫本地發布的電子郵件,使其顯示為來自該域。這樣有助于確保響應返回入站郵件服務器默認:myorigin = $myhostname
(2)inet_interfaces
控制Postfix偵聽傳入電子郵件的網絡接口。如果設置為loopback-only,僅偵聽127.0.0.1和::1,
如果設置為all,則偵聽所有網絡接口。還可以指定特定地址。
默認:inet_interfaces = localhost
(3)mydestination
收到地址為這些域的電子郵件將傳遞至MDA,以進行本地發送。
默認:mydestination = $myhostname, localhost.$mydomain,localhost
(4)mynetworks
IP地址和網絡的逗號分隔列表(采用CIDR表示法)。這些地址和網絡可以通過此MTA轉發至
任何位置,無需進一步身份驗證。
默認:mynetworks = 127.0.0.0/8
(5)relayhost
relayhost轉發所有通過的出站郵件。通常用方括號指定,以阻止MX記錄查找。
默認:relayhost =local_transport
收件地址為$mydestination的郵件的發送方式。默認情況下,設置為local:$myhostname(使用Local MDA將傳入電子郵件發送到/var/spool/mail中的本地郵件存儲位置)
默認:local_transport = local:$myhostname
(6)postconf -d 顯示默認值。
(7)postconf -n顯示不同于默認值的更改。
####westos.com:
vim /etc/postfix/main.cf
116 inet_interfaces = all ##25端口開啟的網絡接口
76 myhostname = westos-mail.westos.com ##指定mta主機名稱
83 mydomain = westos.com ##指定mta的域名
99 myorigin = westos.com/$mydomain ##指定郵件來源結尾(@后面的字符內容)
164 mydestination = $myhostname, $mydomain, localhost ##接收郵件結尾字符的指定
systemctl restart postfix.service
systemctl stop firewalld
28 vim /etc/postfix/main.cf
29 systemctl restart postfix.service
30 systemctl stop firewalld
####qq.com:
vim /etc/postfix/main.cf
116 inet_interfaces = all ##25端口開啟的網絡接口
76 myhostname = qq-mail.qq.com ##指定mta主機名稱
83 mydomain = qq.com ##指定mta的域名
99 myorigin = qq.com/$mydomain ##指定郵件來源結尾(@后面的字符內容)
164 mydestination = $myhostname, $mydomain, localhost ##接收郵件結尾字符的指定
systemctl restart postfix.service
systemctl stop firewalld
8 vim /etc/postfix/main.cf
9 systemctl restartpostfix.service
10 systemctl stop firewalld
測試: 可以互相發郵件
31 mail root@qq.com
32 mailq
33 mail
11 mail
12 mail root@westos.com
13 mailq
3.郵件別名
[root@qq-mail ~]# vim /etc/aliases
別名: 真名 ##郵件別名
別名: :include:filename ##郵件群發
vim filename
user1
user2
postalias /etc/aliases
mail 別名
39 vim /etc/aliases ####配置文件
40 vim /etc/postfix/qun
41 postalias /etc/aliases ###加密
42 systemctl restart postfix.service
43 mail qun@westos.com #####郵件群發
44 mailq
45 mail
46 mail -u student
47 mail admin@westos.com #####root別名admin
48 mailq
49 mail
50 mail admiin@westos.com ####student別名admiin
51 mailq
52 mail -u student
4.通過遠程主機測試郵件服務
真機:
[root@foundation44 ~]# yum install telnet.x86_64 -y
[root@foundation44 ~]# telnet 172.25.254.144 25
Trying 172.25.254.144...
Connected to 172.25.254.144.
Escape character is '^]'.
220 westos-mail.westos.com ESMTP Postfix
ehlo hello ####確定軟件是否裝好
250-westos-mail.westos.com
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
mail from:root@westos.com #####發送方
250 2.1.0 Ok
rcpt to:root@qq.com #####接收方
250 2.1.5 Ok
data ####編輯郵件內容
354 End data with <CR><LF>.<CR><LF>
fhylkhhiplu.kj
.
250 2.0.0 Ok: queued as 4CF3617E86E
quit #####退出
221 2.0.0 Bye
Connection closed by foreign host.
[root@foundation44 yum.repos.d]#
檢測:
(1)westos.com 發送方
[root@westos-mail ~]# mailq
-Queue ID- --Size-- ----Arrival Time---- -Sender/Recipient-------
52431246202 194 Tue May 2301:48:23 root@westos.com
(connect to172.25.254.244[172.25.254.244]:25: No route to host)
root@qq.com
-- 0 Kbytes in 1 Request.
[root@westos-mail ~]# postqueue -f ##重新處理郵件隊列
[root@westos-mail ~]# mailq
Mail queue is empty
[root@westos-mail ~]#
(2)qq.com 接收方
[root@qq-mail ~]# mail
Heirloom Mail version 12.5 7/5/10. Type? for help.
"/var/spool/mail/root": 3 messages 2 new 3 unread
U 1 root Tue May 2300:05 22/734 "qqqq"
>N 2 root@westos.com Tue May 23 01:52 14/494
N 3 root@westos.com Tue May 2301:53 15/497
& quit
Held 3 messages in /var/spool/mail/root
You have mail in /var/spool/mail/root
[root@qq-mail ~]#
5.郵件客戶端的訪問控制
#########限制客戶端
在westos.com:
postconf -e "smtpd_client_restrictions = check_client_accesshash:/etc/postfix/access" ###生成/etc/postfix/main.cf文件中的內容
vim /etc/postfix/main.cf
vim /etc/postfix/access
172.25.254.44 REJECT
postmap /etc/postfix/access ####加密/etc/postfix/access
systemctl restart postfix ####重啟postfix
測試:真機
[root@foundation44 ~]# telnet 172.25.254.144 25
Trying 172.25.254.144...
Connected to 172.25.254.144.
Escape character is '^]'.
220 westos-mail.westos.com ESMTP Postfix
mail from:root@westos.com #####發送方
250 2.1.0 Ok
rcpt to:root@qq.com ####接受方
554 5.7.1 <unknown[172.25.254.44]>: Client host rejected: Accessdenied
#####限制用戶發送
[root@westos-mail ~]# postconf -e"smtpd_sender_restrictions = check_sender_accesshash:/etc/postfix/sender"
[root@westos-mail ~]# vim /etc/postfix/main.cf
[root@westos-mail ~]# vim /etc/postfix/sender
student@westos.com REJECT
[root@westos-mail ~]# cd /etc/postfix
[root@westos-mail postfix]# ls
access canonical header_checks master.cf relocated sender.db virtual
access.db generic main.cf qun sender transport
[root@westos-mail postfix]# systemctl start named
[root@westos-mail postfix]# systemctl restart postfix
測試:
[root@foundation44 ~]# telnet 172.25.254.144 25
Trying 172.25.254.144...
Connected to 172.25.254.144.
Escape character is '^]'.
220 westos-mail.westos.com ESMTP Postfix
mail from:student@westos.com
250 2.1.0 Ok
rcpt to:root@qq.com
554 5.7.1 <student@westos.com>: Sender address rejected: Accessdenied
############限制用戶接收
[root@westos-mail ~]# postconf -e "smtpd_recipient_restrictions =check_sender_access hash:/etc/postfix/recip"
[root@westos-mail ~]# vim /etc/postfix/main.cf
[root@westos-mail ~]# vim /etc/postfix/recip
westos@westos.com REJECT
[root@westos-mail ~]# postmap /etc/postfix/recip
[root@westos-mail ~]# systemctl restart postfix
[root@westos-mail ~]# useradd westos
[root@westos-mail ~]#
測試:
[root@foundation44 ~]# telnet 172.25.254.144 25
Trying 172.25.254.144...
Connected to 172.25.254.144.
Escape character is '^]'.
220 westos-mail.westos.com ESMTP Postfix
mail from:westos@westos.com
250 2.1.0 Ok
rcpt to:westos@westos.com
554 5.7.1 <westos@westos.com>: Sender address rejected: Accessdenied
quit
221 2.0.0 Bye
Connection closed by foreign host.
#########企業郵箱
####出棧地址轉換
1 postconf -d | grep generic
2 postconf -e "smtp_generic_maps = hash:/etc/postfix/generic"
3 vim /etc/postfix/main.cf
4 vim /etc/postfix/generic
westos@westos.com hello@sb.com
真域名 假域名
5 postmap /etc/postfix/generic
6 systemctl restart postfix
7 su - westos
測試:[westos@westos-mail ~]$ history
1 mail root@qq.com
2 mailq
[root@qq-mail ~]# mail
##入戰地址轉換
1. dns mx 記錄解析先做好
17 vim /etc/named.rfc1912.zones
18 cp-p qq.com.zone sb.com.zone
19 vim sb.com.zone
20 systemctl restart named
21 dig -t mx sb.com
2.
26 postconf -e"virtual_alias_maps = hash:/etc/postfix/virtual"
27 vim /etc/postfix/main.cf
28 vim /etc/postfix/virtual
虛擬名字 真實用戶
hello@sb.com westos@westos.com
29 postmap /etc/postfix/virtual
30 systemctl restart postfix
31 su - westos
測試:
[root@qq-mail ~]# mail hello@sb.com
[westos@westos-mail ~]$ mail
##########################
####### dovecot ##########
##########################
1.
dovecot 用來提供收件協議
pop3 110
imap 143
imaps 993
pop3s 995
給定用戶名稱,用戶密碼,dovecot程序代我們去看這個用戶的郵件文件
###############收郵件######
2.
yum install dovecot -y
systemctl start dovecot
netstat -antlpe | grep dovecot
3.
vim /etc/dovecot/dovecot.conf
24 protocols = imap pop3 lmtp
48 login_trusted_networks = 0.0.0.0/0
49 disable_plaintext_auth = no
vim /etc/dovecot/conf.d/10-mail.conf
30 mail_location = mbox:~/mail:INBOX=/var/mail/%u ##防止別人收到你的郵件
passwd westos ####
mail westos
4.
[root@westos-mail ~]# su - westos
[westos@westos-mail ~]$ mkdir mail/.imap/ -p
[westos@westos-mail ~]$ touch mail/.imap/INBOX
[westos@westos-mail ~]$ logout
5.自動撰寫 mail/.imap
mkdir /etc/skel/mail/.imap/ -p
touch /etc/skel/mail/.imap/INBOX
/etc/skel #####骨架目錄
14 mkdir /etc/skel/mail/.imap/ -p
15 touch /etc/skel/mail/.imap/INBOX
16 useradd lee
17 cd /home/lee
18 ll
19 ls mail/ -a
20 ls mail/.imap/INBOX
21 passwd lee
22 mail lee
測試
真機:
[root@foundation44 ~]# yum install mutt -y
[root@foundation44 ~]# mutt -fpop://westos@172.25.254.144
2 kept, 0 deleted.
[root@foundation44 ~]# mutt -fpop://lee@172.25.254.144
1 kept, 0 deleted.
選擇O
輸入密碼
按Enter
######雷鳥######
1 下載 thunderbird-31.2.0-1.el7.x86_64.rpm
2 安裝
yum install /home/kiosk/Desktop/thunderbird-31.2.0-1.el7.x86_64.rpm -y
3 (1)打開雷鳥
(2)
4驗證:
[root@qq-mail ~]# mail
##########mariadb;dovecot;postfix########
一
準備工作:
(1)#####postfix###
westos.com:
201 mv /etc/postfix/main.cf /mnt/
202 yum reinstall postfix -y
203 vim /etc/postfix/main.cf
116 inet_interfaces = all ##25端口開啟的網絡接口
76 myhostname = qq-mail.qq.com ##指定mta主機名稱
83 mydomain = qq.com ##指定mta的域名
99 myorigin = qq.com/$mydomain ##指定郵件來源結尾(@后面的字符內容)
164 mydestination = $myhostname, $mydomain, localhost ##接收郵件結尾字符的指定
204 systemctl restart postfix
(2)######mariadb####
205 yum install http php php-mysql mariadb-server -y
206 systemctl start mariadb
208 vim /etc/my.cnf ###mysqul的配置文件
14 skip-networking=1
209 systemctl restart mariadb ###重啟mariadb服務
210 mysql_secure_installation ###mysql安全內容配置
所有都按Enter鍵
下載
215 scproot@172.25.254.44:/home/kiosk/Desktop/phpMyAdmin-3.4.0-all-languages.tar.bz2 /var/www/html
###########下載 壓縮包
216 cd /var/www/html
217 ls
218 tar jxf phpMyAdmin-3.4.0-all-languages.tar.bz2
####解壓壓縮包到/var/www/html
219 ls
220 rm -fr *.bz2
221 ls
222 mv phpMyAdmin-3.4.0-all-languages/ mysqladmain #### 將安裝包下的所有文件移動到 mysqladmin
223 cd mysqladmain/
224 ls
225 cp config.sample.inc.php config.inc.php ###復制配置文件
226 vim config.inc.php ###寫配置文件
$cfg['blowfish_secret'] = 'mysql'; /* YOU MUST FILL IN THIS FOR COOKIE AUTH!*/
227 systemctl restart httpd
真機:
打開瀏覽器訪問:http://172.25.254.144/myadmin/
westos.com:
228 mysql -uroot -pqwer
MariaDB [(none)]> create userpostuser@localhost identified by 'postuser'; ####建立postuser用戶 ,本地登陸
MariaDB [(none)]> grantselect,update,insert on email.* to postuser@localhost; ####### 本機登陸postuser,授權
MariaDB [(none)]> select * fromemail.emailuser;###查詢email.emailuser表中的所有內容
MariaDB [(none)]> quit
測試:
32 cd /etc/postfix
34 vim mailuser.cf ####用戶名稱查詢
hosts = localhost #####數據庫所在的主機
user = postuser #####登陸數據庫的用戶
password = postuser #####登陸數據庫的密碼
dbname = email #####postfix要查詢的名字
table = emailuser ######postfix要查詢的表的名字
select_field = username #####postfix要查詢的字段
where_field = username ####用戶給定postfix的查詢條件
35 postmap -q "lee@lee.com" mysql:/etc/postfix/mailuser.cf
36 cp mailuser.cf maildomain.cf
37 vim maildomain.cf #### 用戶域名查詢
hosts = localhost
user = postuser
password = postuser
dbname = email
table = emailuser
select_field = domain
where_field = domain
38 postmap -q "lee.com" mysql:/etc/postfix/maildomain.cf
39 cp mailuser.cf mailbox.cf
40 vim mailbox.cf ####用戶郵箱位置查詢
hosts = localhost
user = postuser
password = postuser
dbname = email
table = emailuser
select_field = maildir
where_field = username
41 postmap -q "lee@lee.com" mysql:/etc/postfix/mailbox.cf
42 ls
43 cat mailuser.cf
44 cat maildomain.cf
45 cat mailbox.cf
46 history
二##配置postfix
[root@westos-mail ~]# groupadd -g 666 vmail
[root@westos-mail ~]# useradd -s /sbin/nologin -u 666 vmail -g 666
[root@westos-mail ~]# id vmail
uid=666(vmail) gid=666(vmail) groups=666(vmail)
[root@westos-mail ~]# postconf -e "virtual_mailbox_base =/home/vmail"
##設定虛擬用戶的郵件目錄
[root@westos-mail ~]# postconf -e"virtual_uid_maps = static:666"
##虛擬用戶建立文件的uid
[root@westos-mail ~]# postconf -e "virtual_gid_maps =static:666"
##虛擬用戶建立文件的gid
[root@westos-mail ~]# postconf -e "virtual_alias_maps =mysql:/etc/postfix/mailuser.cf"
[root@westos-mail ~]# postconf -e "virtual_mailbox_domains =mysql:/etc/postfix/maildomain.cf"
[root@westos-mail ~]# postconf -e "virtual_mailbox_maps =mysql:/etc/postfix/mailbox.cf"
[root@westos-mail ~]# vim/etc/postfix/main.cf
[root@westos-mail ~]# systemctl restartpostfix
[root@westos-mail ~]# ll/etc/postfix/mailbox.cf
-rw-r--r--. 1 root root 134 May 23 09:05 /etc/postfix/mailbox.cf
[root@westos-mail ~]# ll /etc/postfix/mailuser.cf
-rw-r--r--. 1 root root 135 May 23 09:03 /etc/postfix/mailuser.cf
[root@westos-mail ~]# ll /etc/postfix/maildomain.cf
-rw-r--r--. 1 root root 131 May 23 09:04 /etc/postfix/maildomain.cf
修改郵箱位置
測試:
[root@westos-mail ~]# cd /home/vmail
[root@westos-mail vmail]# ls
[root@westos-mail vmail]# mail lee@lee.com
Subject: abcd
abcd
.
EOT
[root@westos-mail vmail]# ls
lee.com
[root@westos-mail vmail]# cd lee.com
[root@westos-mail lee.com]# ls
lee
[root@westos-mail lee.com]# cd lee
[root@westos-mail lee]# ls
cur new tmp
[root@westos-mail lee]# catnew/1495545556.Vfd01I1a9eecdM433309.westos-mail.westos.com
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。