您好,登錄后才能下訂單哦!
SMTP(二)
telnet遠程鏈接:(誰都可以鏈接,存在安全隱患)
telnet:禁止誰遠程鏈接我的主機發送郵件(任何我主機的用戶都不能被鏈接)
vim /etc/postfix/access
172.25.254.131REJECT
postmap access(生成access.db加密文件)
postconf -d | grep client
postconf-e "smtpd_client_restrictions =check_client_accesshash:/etc/postfix/access"(check_client_access:檢測客戶)
vim /etc/postfix/main.cf
systemctl restart postfix.service
測試:
刪除此設置
vim /etc/postfix/access(刪除禁止)
postmap access(重新加密)
systemctl restart postfix.service
設置我的哪個主機用戶不能被遠程鏈接(本地可以)發送郵件,但是這個用戶可以收到郵件(沒用被禁止的主機用戶可以鏈接)
vim /etc/postfix/sender
postmap sender(寫完整的用戶名)
postconf -d | grep sender
postconf-e "smtpd_client_restrictions =check_sender_accesshash:/etc/postfix/sender"(check_sender_access:檢測用戶)
systemctl restart postfix.service
測試:
我的哪一個主機用戶不能收郵件(遠程登陸的不可以,本地發送的也不可以收到)
修改之前(student用戶可以收郵件)
vim /etc/postfix/recip
postconf -d | grep recip
postconf-e "smtpd_recipient_restrictions = check_recipient_accesshash:/etc/postfix/recip"
systemctl restart postfix.service
測試:
登陸驗證用戶接收郵件:
yum install dovecot –y
vim /etc/dovecot/dovecot.conf
disable_plaintext_auth = no
cd /etc/dovecot/conf.d
vim 10-mail.conf
mail_location = mbox:~/mail:INBOX=/var/mail/%u
測試:mutt -f imap://studnet@172.25.254.231(前提是在/home/studnet下有/mail/.iamp/INDOX這個文件存在)
數據庫連接郵箱:
網頁管理數據庫:
創建數據庫:mail
創建表格:muser
創建用戶:
給權限:
查詢:
cd /etc/postfix
vim mysql-user.cf
hosts = localhost
user = postfix
password = postfix
dbname = email
table = muser
select_field = username
where_field = username
查詢測試:postmap -q "admin@dd.org" /etc/postfix/mysql-user.cf
vim mysql-domain.cf
hosts = localhost
user = postfix
password = postfix
dbname = email
table = muser
select_field = domain
where_field = domain
查詢測試:postmap -q "dd.org" /etc/postfix/mysql-domain.cf
vim mysql-maildri.cf
hosts = localhost
user = postfix
password = postfix
dbname = email
table = muser
select_field = mailder
where_field = username
查詢測試:postmap -q "admin@dd.org" /etc/postfix/mysql-maildir.cf
給數據庫里面的虛擬用戶發送郵件
groupadd -g 666 vmail
useradd -g 666 -u 666 vmain
virtual_gid_maps = static:666
virtual_uid_maps = static:666
virtual_mailbox_base = /home/vmail
virtual_alias_maps = mysql:/etc/postfix/mysql-user.cf
virtual_mailbox_domains = mysql:/etc/postfix/mysql-domain.cf
virtual_mailbox_maps = mysql:/etc/postfix/mysql-maildir.cf
cd /home/vmail
數據庫里面的虛擬用戶收郵件
vim dovecot.conf
protocols = imap pop3 lmtp
disable_plaintext_auth = no
vim dovecot-sql.conf.ext
driver = mysql
connect = host=localhost dbname=email user=postfix password=postfix
default_pass_scheme = PLAIN
password_query = \
SELECT username, domain, password \
FROM muser WHERE username = '%u' AND domain ='%d'
user_query = SELECT mailder, 666 AS uid, 666 AS gid FROM muserWHERE username = '%u'
(認真 細心 一定不要寫錯哦 ~)
vim 10-auth.conf
!include auth-system.conf.ext
!include auth-sql.conf.ext
vim 10-mail.conf
mail_location
maildir:/home/vmail/%d/%n
first_valid_uid = 666
first_valid_gid = 666
郵件空殼:
空殼:
配置dns:
vim /etc/named.rfc1912.zones
zone"dd.org" IN {
type master;
file "dd.org.zone";
allow-update { none; };
};
vim/var/name/dd.org.zone
(請參照前面所講的DNS的知識~)
測試:(dd.org域真實指向的是172.25.254.131 )
配置/etc/postfix/main.cf
myhostname =dd.dd.com(真實空殼主機名)
mydomain = dd.com(真實域名)
myorigin = dd.org (做哪個域的空殼)
inet_interfaces =all(打開25接口)
local_transport =error:local delivery disabled(如果給“空殼”傳送郵件會報錯)
mydestination= (什么都不寫:因為作為空殼不接收處理任何郵件)
relayhost =172.25.254.231(主處理郵件的服務器)
systemctl restartpostfix.service
真實的接受郵件的服務器:(MTA:郵件服務器)
vim/etc/postfix/main.cf
mynetworks = 172.25.254.131 (我的空殼是誰)
systemctl restartpostfix.service
測試:
給admin@dd.org
發送一封郵件
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。