您好,登錄后才能下訂單哦!
##########postfix+mariadb#######
發送郵件
準備工作
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
##添加數據庫用戶,并給其授權
1.
vim /etc/postfix/mailuser.cf ##用戶名稱查詢
host = localhost ##數據庫所在主機
user = postuser ##登陸數據庫的用戶
password = postuser ##登陸數據庫的用戶密碼
dbname = email ##postfix要查詢的庫的名稱
table = emailtable ##postfix要查詢的表的名稱
select_field = username ##postfix要查詢的字段
where_field = username ##用戶給定postfix的查詢條件
vim /etc/postfix/maildomain.cf ##用戶域名查詢
host = localhost
user = postuser
password = postuser
dbname = email
table = emailtable
select_field = domain
where_field = domain
vim /etc/postfix/mailbox.cf ##用戶郵箱位置查詢
host = localhost
user = postuser
password = postuser
dbname = email
table = emailtable
select_field = maildir
where_field = username
測試:
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/
####配置postfix
groupadd -g 123 vmail ##添加用戶組并指定gid為123
useradd -s /sbin/nologin -u 123 vmail -g 123 ##添加用戶,并指定uid和gid為123
postconf -d |grep virtual ##查詢virtual
postconf -e "virtual_mailbox_base = /home/vmail" ##設定虛擬用戶的郵件目錄
postconf -e "virtual_uid_maps = static:123" ##虛擬用戶建立文件的uid
postconf -e "virtual_gid_maps = static:123" ##虛擬用戶建立文件的gid
postconf -e "virtual_alias_maps = mysql:/etc/postfix/mailuser.cf" ##指定mysql查找主機
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服務
##測試:發送給cui@cui.com的郵件在/home/vmail/cui.com/cui/new/里找到
############dovecot+mysql############
接收郵件
1.
yum install dovecot dovecot-mysql -y
##dovecot是一個開源的 IMAP 和 POP3 郵件服務器,支持 Linux,支持發送郵件
##dovecot-mysql dovecot軟件的插件,讓此軟件可以識別mysql
2.
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-auth.conf
123 !include auth-sql.conf.ext ##開啟mysql的認證方式
##生成dovecot讀取mysql的配置
cp /usr/share/doc/dovecot-2.2.10/example-config/dovecot-sql.conf.ext/etc/dovecot/dovecot-sql.conf.ext
vim /etc/dovecot/dovecot-sql.conf.ext
32 driver = mysql ##數據庫類型
71 connect = host=localhost dbname=emailuser=postuser password=postuser ##查詢時用到的庫,用戶,密碼
78 default_pass_scheme = PLAIN ##默認認證方式為明文
107 password_query = \ ##查詢密碼匹配
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' ##查詢郵件內容
vim /etc/dovecot/conf.d/10-mail.conf
30 mail_location =maildir:/home/vmail/%d%n ##指定郵件位置
168 first_valid_uid = 123 ##郵件文件查詢用戶身份
175 first_valid_gid = 123
systemctl restart dovecot
測試:
[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.空殼郵件
westos-mail主機為真機
qq-mail主機為空殼
在qq-mail上執行
vim /etc/postfix/main.cf
myorigin = westos.com ## 設置為真實的主機域名
mydestination = ##空殼郵件不接受郵件,所以不設置
relayhost = 172.25.254.162 ##接替的真實主機的IP
##測試:空殼主機給本機root發送郵件但不接收,162主機接收郵件
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。