溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶(hù)服務(wù)條款》

3-unit4 postfix+mysql

發(fā)布時(shí)間:2020-06-19 22:40:04 來(lái)源:網(wǎng)絡(luò) 閱讀:298 作者:cuijb0221 欄目:數(shù)據(jù)庫(kù)

##########postfix+mariadb#######
發(fā)送郵件

準(zhǔn)備工作
yum install httpd php php-mysql mariadb-server -y

##配置mysql

config phpmyadmin
config mariadb
mysql_secure_installation
create db
create table
create usermessage
create dbuser
3-unit4 postfix+mysql


3-unit4 postfix+mysql

 ##添加數(shù)據(jù)庫(kù)用戶(hù),并給其授權(quán)

3-unit4 postfix+mysql

3-unit4 postfix+mysql



1.
vim /etc/postfix/mailuser.cf    ##用戶(hù)名稱(chēng)查詢(xún)
host = localhost        ##數(shù)據(jù)庫(kù)所在主機(jī)
user = postuser         ##登陸數(shù)據(jù)庫(kù)的用戶(hù)
password = postuser     ##登陸數(shù)據(jù)庫(kù)的用戶(hù)密碼
dbname = email          ##postfix要查詢(xún)的庫(kù)的名稱(chēng)
table = emailtable      ##postfix要查詢(xún)的表的名稱(chēng)
select_field = username     ##postfix要查詢(xún)的字段
where_field = username      ##用戶(hù)給定postfix的查詢(xún)條件

vim /etc/postfix/maildomain.cf  ##用戶(hù)域名查詢(xún)
host = localhost
user = postuser
password = postuser
dbname = email
table = emailtable
select_field = domain
where_field = domain

vim /etc/postfix/mailbox.cf     ##用戶(hù)郵箱位置查詢(xún)
host = localhost
user = postuser
password = postuser
dbname = email
table = emailtable
select_field = maildir
where_field = username 


3-unit4 postfix+mysql
測(cè)試:
 postmap -q "cui@cui.com"mysql:/etc/postfix/mailuser.cf
cui@cui.com
 postmap -q "cui.com"mysql:/etc/postfix/maildomain.cf
cui.com
 postmap -q "cui@cui.com"mysql:/etc/postfix/mailbox.cf
/mnt/cui.com/cui/
3-unit4 postfix+mysql

####配置postfix
groupadd -g 123 vmail        ##添加用戶(hù)組并指定gid為123

useradd -s /sbin/nologin -u 123 vmail -g 123    ##添加用戶(hù),并指定uid和gid為123

3-unit4 postfix+mysql
postconf -d |grep virtual   ##查詢(xún)virtual
3-unit4 postfix+mysql

postconf -e "virtual_mailbox_base = /home/vmail"    ##設(shè)定虛擬用戶(hù)的郵件目錄
postconf -e "virtual_uid_maps = static:123"     ##虛擬用戶(hù)建立文件的uid
postconf -e "virtual_gid_maps = static:123"     ##虛擬用戶(hù)建立文件的gid
postconf -e "virtual_alias_maps = mysql:/etc/postfix/mailuser.cf"   ##指定mysql查找主機(jī)
postconf -e "virtual_mailbox_domains =mysql:/etc/postfix/maildomain.cf"    ##指定mysql查找域名
postconf -e "virtual_mailbox_maps = mysql:/etc/postfix/mailbox.cf"  ##指定mysql查找郵箱

systemctl restart postfix        ##重啟postfix服務(wù)

3-unit4 postfix+mysql
3-unit4 postfix+mysql

3-unit4 postfix+mysql

##測(cè)試:發(fā)送給cui@cui.com的郵件在/home/vmail/cui.com/cui/new/里找到

3-unit4 postfix+mysql

3-unit4 postfix+mysql



############dovecot+mysql############

接收郵件
1.
yum install dovecot dovecot-mysql -y

##dovecot是一個(gè)開(kāi)源的 IMAP 和 POP3 郵件服務(wù)器,支持 Linux,支持發(fā)送郵件

##dovecot-mysql  dovecot軟件的插件,讓此軟件可以識(shí)別mysql
2.
vim /etc/dovecot/dovecot.conf
 24 protocols = imap pop3 lmtp      ##支持收件協(xié)議
 48 login_trusted_networks = 0.0.0.0/0  ##信任網(wǎng)絡(luò)
 49 disable_plaintext_auth = no     ##開(kāi)啟明文認(rèn)證
3-unit4 postfix+mysql
3-unit4 postfix+mysql

vim /etc/dovecot/conf.d/10-auth.conf
123 !include auth-sql.conf.ext      ##開(kāi)啟mysql的認(rèn)證方式 

3-unit4 postfix+mysql

##生成dovecot讀取mysql的配置
cp /usr/share/doc/dovecot-2.2.10/example-config/dovecot-sql.conf.ext/etc/dovecot/dovecot-sql.conf.ext
3-unit4 postfix+mysql

vim /etc/dovecot/dovecot-sql.conf.ext
 32 driver = mysql          ##數(shù)據(jù)庫(kù)類(lèi)型
 71 connect = host=localhost dbname=emailuser=postuser password=postuser   ##查詢(xún)時(shí)用到的庫(kù),用戶(hù),密碼
 78 default_pass_scheme = PLAIN     ##默認(rèn)認(rèn)證方式為明文
107 password_query = \          ##查詢(xún)密碼匹配
108   SELECT username, domain, password\
109   FROM emailuser WHERE username ='%u' AND domain = '%d'   
125 user_query = SELECT maildir, 123 AS uid, 123 AS gid FROM emailuser WHEREusername = '%u'    ##查詢(xún)郵件內(nèi)容
3-unit4 postfix+mysql
3-unit4 postfix+mysql
3-unit4 postfix+mysql
3-unit4 postfix+mysql


vim /etc/dovecot/conf.d/10-mail.conf
 30 mail_location =maildir:/home/vmail/%d%n    ##指定郵件位置
168 first_valid_uid = 123           ##郵件文件查詢(xún)用戶(hù)身份
175 first_valid_gid = 123
3-unit4 postfix+mysql
3-unit4 postfix+mysql
systemctl restart dovecot


測(cè)試:
[root@foundation62 ~]# telnet 172.25.254.150 110
Trying 172.25.254.150...
Connected to 172.25.254.150.
Escape character is '^]'.
+OK [XCLIENT] Dovecot ready.
user cui@cui.com
+OK
pass cui
+OK Logged in.
quit
+OK Logging out.
Connection closed by foreign host.
[root@foundation62 ~]#

3-unit4 postfix+mysql
 

3.空殼郵件

westos-mail主機(jī)為真機(jī)

qq-mail主機(jī)為空殼

在qq-mail上執(zhí)行

vim   /etc/postfix/main.cf

myorigin = westos.com    ## 設(shè)置為真實(shí)的主機(jī)域名3-unit4 postfix+mysql

mydestination =          ##空殼郵件不接受郵件,所以不設(shè)置

3-unit4 postfix+mysql

relayhost = 172.25.254.162  ##接替的真實(shí)主機(jī)的IP

3-unit4 postfix+mysql

##測(cè)試:空殼主機(jī)給本機(jī)root發(fā)送郵件但不接收,162主機(jī)接收郵件

3-unit4 postfix+mysql

3-unit4 postfix+mysql

向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI