創(chuàng)新互聯(lián)公司主營城中網(wǎng)站建設(shè)的網(wǎng)絡(luò)公司,主營網(wǎng)站建設(shè)方案,app軟件定制開發(fā),城中h5小程序開發(fā)搭建,城中網(wǎng)站營銷推廣歡迎城中等地區(qū)企業(yè)咨詢
#################postfix###################
1.postfix提供smtp協(xié)議用來投遞郵件
默認端口 25
默認發(fā)布目錄 /var/log/maillog ##服務(wù)日志
mail root @..... 發(fā)郵件
主題:
內(nèi)容....
.
mailq ###查看郵件隊列
postqueue -f ###重新處理郵件隊列
默認情況下郵件端口只在127.0.0.1上開啟
2.
配置
vim /etc/postfix/main.cf
76 myhostname = westos-mail.westos.com ###25端口開啟的網(wǎng)絡(luò)借口
83 mydomain = westos.com ###指定mta的域名
99 myorigin = westos.com ###制定郵件來源結(jié)尾(@后面的字符內(nèi)容)
116 inet_interfaces = all ###25端口開啟的網(wǎng)絡(luò)借口
164 mydestination = $myhostname, $mydomain, localhost ###接受郵件字符的指定
systemctl restart postfix.service
systemctl stop firewalld
3.郵件別名
[root@westos-mail named]# vim /etc/aliases
97 admin: root ##郵件別名
98 moreuser: :include:/etc/postfix/moreuser ##郵件群發(fā)
[root@qq-mail ~]# vim /etc/postfix/moreuser
user1
user2
[root@qq-mail ~]# systemctl restart postfix.service
mail -u 用戶名
postsuper -d 刪除排隊郵件
postqueue -f 重新發(fā)送排隊的郵件
postalias /etc/aliases
4.通過遠程主機發(fā)送郵件
[kiosk@foundation75 Desktop]$ yum install -y telnet
[root@foundation75 Desktop]# telnet 172.25.254.101 25
Trying 172.25.254.101...
Connected to 172.25.254.101.
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>
qwdq
qwdeq
qeq
.
測試
[root@qq-mail ~]# mail
Heirloom Mail version 12.5 7/5/10. Type ? for help.
"/var/spool/mail/root": 2 messages 1 new 2 unread
U 1 root Tue May 23 09:45 25/739 "qq"
>N 2 root@westos.com Tue May 23 09:53 15/494
& 2
Message 2:
From root@westos.com Tue May 23 09:53:48 2017
Return-Path: <root@westos.com>
X-Original-To: root@qq.com
Delivered-To: root@qq.com
Status: R
qwdq
qwdeq
qeq
5.郵件客戶端的訪問控制
在mta上
postconf -e "smtpd_client_restrictions = check_client_access hash:/etc/postfix/access"
root@westos-mail named]# vim /etc/postfix/main.cf
681 smtpd_client_restrictions = check_client_access hash:/etc/postfix/acce ss
root@westos-mail named]# vim /etc/postfix/access
476 172.25.254.95 REJECT
[root@westos-mail named]# postmap /etc/postfix/access
[root@westos-mail named]# ls
data named.ca named.localhost qq.com.zone westos.com.zone
dynamic named.empty named.loopback slaves
[root@westos-mail named]# cd /etc/postfix
[root@westos-mail postfix]# ls
access canonical header_checks master.cf transport
access.db generic main.cf relocated virtual
測試
[root@test Desktop]# telnet 172.25.254.195 25
Trying 172.25.254.195...
Connected to 172.25.254.195.
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.95]>: Client host rejected: Access denied
##限制用戶發(fā)送
[root@westos-mail postfix]# postconf -e "smtpd_sender_restrictions = check_sender_access hash:/etc/postfix/sender"
[root@westos-mail postfix]# vim /etc/postfix/main.cf
681 smtpd_sender_restrictions = check_sender_access hash:/etc/postfix/sender
[root@westos-mail postfix]# vim /etc/postfix/sender
student@westos.com REJECT
[root@westos-mail postfix]# postmap /etc/postfix/sender
[root@westos-mail postfix]# ls
access canonical header_checks master.cf sender transport
access.db generic main.cf relocated sender.db virtual
[root@westos-mail postfix]# systemctl restart postfix.service
測試
[root@foundation75 Desktop]# telnet 172.25.254.101 25
Trying 172.25.254.101...
Connected to 172.25.254.101.
Escape character is '^]'.
220 westos-mail.westos.com ESMTP Postfix
mail from:student@westos.com
250 2.1.0 Ok
rcpt to:root@westos.com
554 5.7.1 <student@westos.com>: Sender address rejected: Access denied
##限制用戶接收
[root@westos-mail postfix]# postconf -e "smtpd_sender_restrictions = check_recipient_access hash:/etc/postfix/recip"
[root@westos-mail postfix]# vim /etc/postfix/main.cf
smtpd_sender_restrictions = check_recipient_access hash:/etc/postfix/recip
[root@westos-mail postfix]# vim /etc/postfix/recip
westos@westos.com REJECT
[root@westos-mail postfix]# postmap /etc/postfix/recip
[root@westos-mail postfix]# systemctl restart postfix.service
測試
[root@foundation75 Desktop]# telnet 172.25.254.101 25
Trying 172.25.254.101...
Connected to 172.25.254.101.
Escape character is '^]'.
220 westos-mail.westos.com ESMTP Postfix
mail from:root@qq.com
250 2.1.0 Ok
rcpt to:westos@westos.com
554 5.7.1 <westos@westos.com>: Recipient address rejected: Access denied
#出站地址偽裝
做好DNS解析
[root@westos-mail named]# postconf -e "smtp_generic_maps = hash:/etc/postfix/generic"
[root@westos-mail named]# vim /etc/postfix/main.cf
smtp_generic_maps = hash:/etc/postfix/generic
[root@westos-mail named]# vim /etc/postfix/generic
westos@westos.com hello@sb.com
[root@westos-mail named]# postmap /etc/postfix/generic
[root@westos-mail named]# cd /etc/postfix/
[root@westos-mail postfix]# ls
access canonical generic.db main.cf recip relocated sender.db virtual
access.db generic header_checks master.cf recip.db sender transport
[root@westos-mail postfix]# id westos
uid=1001(westos) gid=1001(westos) groups=1001(westos)
測試
From hello@sb.com Tue May 23 11:55:08 2017
Return-Path: <hello@sb.com>
X-Original-To: root@qq.com
Delivered-To: root@qq.com
Date: Tue, 23 May 2017 11:55:08 -0400
To: root@qq.com
Subject: qdq
User-Agent: Heirloom mailx 12.5 7/5/10
Content-Type: text/plain; charset=us-ascii
From: hello@sb.com
Status: R
##入站地址轉(zhuǎn)換
做好dns解析
[root@westos-mail postfix]# postconf -e "virtual_alias_maps = hash:/etc/postfix/virtual"
[root@westos-mail postfix]# vim /etc/postfix/virtual
295 hello@sb.com westos@westos.com
[root@westos-mail postfix]# vim /etc/postfix/main.cf
virtual_alias_maps = hash:/etc/postfix/virtual
[root@westos-mail postfix]# postmap /etc/postfix/virtual
[root@westos-mail postfix]# systemctl restart postfix.service
[root@westos-mail postfix]# mail hello@sb.com
Subject: qwdq
qwdq
dq
wdq
.
EOT
測試
[root@westos-mail postfix]# mail -u westos
Heirloom Mail version 12.5 7/5/10. Type ? for help.
"/var/mail/westos": 1 message 1 new
>N 1 root Tue May 23 12:10 20/560 "qwdq"
& 1
Message 1:
From root@westos.com Tue May 23 12:10:01 2017
Return-Path: <root@westos.com>
X-Original-To: hello@sb.com
Delivered-To: westos@westos.com
Date: Tue, 23 May 2017 12:10:00 -0400
To: hello@sb.com
Subject: qwdq
User-Agent: Heirloom mailx 12.5 7/5/10
Content-Type: text/plain; charset=us-ascii
From: root@westos.com (root)
Status: R
######################################
###########dovecot####################
1.dovecot用來提供收件協(xié)議
pop3 110
imap 143
imaps 993
pop3s 995
給定用戶名稱,用戶密碼,dovecot程序代替我們?nèi)タ催@個用戶的郵件文件
2.yum intsall -y dovecot
3.
[root@westos-mail named]# vim /etc/dovecot/dovecot.conf
24 protocols = imap pop3 lmtp
48 login_trusted_networks = 0.0.0.0/0
49 disable_plaintext_auth = no
[root@westos-mail named]# vim /etc/dovecot/conf.d/10-mail.conf
30 mail_location = mbox:~/mail:INBOX=/var/mail/%u
[root@westos-mail ~]# su westos
[westos@westos-mail root]$ cd ~
[westos@westos-mail ~]$ mkdir /home/westos/mail/.imap -p
[westos@westos-mail ~]$ touch /home/westos/mail/.imap/INBOX
[root@westos-mail westos]# passwd westos
Changing password for user westos.
New password:
BAD PASSWORD: The password is a palindrome
Retype new password:
passwd: all authentication tokens updated successfully.
[root@westos-mail westos]# systemctl restart dovecot.service
[root@westos-mail ~]# mkdir /etc/skel/mail/.imap -p
[root@westos-mail ~]# touch /etc/skel/mail/.imap/INBOX
[root@westos-mail ~]# useradd zhang
[root@westos-mail ~]# passwd zhang
Changing password for user zhang.
New password:
BAD PASSWORD: The password is a palindrome
Retype new password:
passwd: all authentication tokens updated successfully.
[root@westos-mail ~]# systemctl restart dovecot.service
測試
主機安裝mutt
[root@foundation75 Desktop]# mutt -f pop://zhang@172.25.254.101
安裝雷鳥
用真機
rpm -ivh thunderbird-31.2.0-1.el7.x86_64.rpm
接下來進行以下操作
進去之后進行登陸并且給westos@westom.com恢復(fù)郵件
測試
[root@westos-mail ~]# mail
Heirloom Mail version 12.5 7/5/10. Type ? for help.
"/var/spool/mail/root": 2 messages 1 new
1 root Tue May 23 11:22 21/572 "qwew"
>N 2 westos@westos.com Wed May 24 11:52 32/940 "Re:123"
& 2
Message 2:
From westos@westos.com Wed May 24 11:52:52 2017
Return-Path: <westos@westos.com>
X-Original-To: root@westos.com
Delivered-To: root@westos.com
Date: Wed, 24 May 2017 23:52:52 +0800
From: "westos@westos.com" <westos@westos.com>
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/
31.2.0
To: root <root@westos.com>
Subject: Re:123
Content-Type: text/plain; charset=UTF-8; format=flowed
Status: R
################postfix+mariadb##############
[root@westos-mail ~]# yum install -y httpd php php-MySQL mariadb-server
[root@westos-mail ~]# systemctl start mariadb
[root@westos-mail ~]# vim /etc/my.cnf
[root@westos-mail ~]# systemctl restart postfix.service
[root@westos-mail ~]# systemctl restart mariadb.service
[root@westos-mail ~]# mysql_secure_installation
[root@westos-mail ~]# cd /var/www/html
[root@westos-mail html]# ls
phpMyAdmin-3.4.0-all-languages.tar.bz2
[root@westos-mail html]# tar jxf phpMyAdmin-3.4.0-all-languages.tar.bz2
[root@westos-mail html]# rm -fr *.bz2
[root@westos-mail html]# ls
phpMyAdmin-3.4.0-all-languages
[root@westos-mail html]# mv phpMyAdmin-3.4.0-all-languages/ myadmin
[root@westos-mail html]# ls
myadmin
[root@westos-mail html]# cd myadmin
[root@westos-mail myadmin]# cp config.sample.inc.php config.inc.php
[root@westos-mail myadmin]# vim config.inc.php
[root@westos-mail myadmin]# systemctl restart httpd
[root@westos-mail myadmin]# mysql -uroot -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 32
Server version: 5.5.35-MariaDB MariaDB Server
Copyright (c) 2000, 2013, Oracle, Monty Program Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> create user postuser@localhost identified by 'postuser';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> grant select,update,insert on email.* to postuser@localhost;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> quit
Bye
[root@westos-mail myadmin]# mysql -upostuser -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 33
Server version: 5.5.35-MariaDB MariaDB Server
Copyright (c) 2000, 2013, Oracle, Monty Program Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> select * from email.emailuser;
+-------------+----------+---------+-------------------+
| username | password | domain | maildir |
+-------------+----------+---------+-------------------+
| lee@lee.com | lee | lee.com | /mnt/lee.com/lee/ |
+-------------+----------+---------+-------------------+
[root@westos-mail ~]# cd /etc/postfix/
[root@westos-mail postfix]# vim mailuser.cf ####用戶名查詢
1 hosts = localhost ##數(shù)據(jù)庫所在的主機
2 user = postuser ##登陸數(shù)據(jù)庫的用戶
3 password = postuser ##登陸數(shù)據(jù)庫的密碼
4 dbname = email ##postfix要查詢的名稱
5 table = emailuser ##postfix要查詢表的名稱
6 select_field = username ##postfix要查詢的字段
7 where_field = username ##用戶給定postfix的查詢條件
[root@westos-mail postfix]# postmap -q "lee@lee.com" mysql:/etc/postfix/mailuser.cf
lee@lee.com
[root@westos-mail postfix]# vim maildomain.cf ####用戶域名查詢
1 hosts = localhost
2 user = postuser
3 password = postuser
4 dbname = email
5 table = emailuser
6 select_field = domain
7 where_field = domain
[root@westos-mail postfix]# postmap -q "lee.com" mysql:/etc/postfix/maildomain.cf
lee.com
[root@westos-mail postfix]# vim mailbox.cf ####用戶郵箱位置查詢
1 hosts = localhost
2 user = postuser
3 password = postuser
4 dbname = email
5 table = emailuser
6 select_field = maildir
7 where_field = username
[root@westos-mail postfix]# postmap -q "lee@lee.com" mysql:/etc/postfix/mailbox.cf
/mnt/lee.com/lee/
附圖
####配置postfix
[root@westos-mail ~]# groupadd -g 666 vmail
[root@westos-mail ~]# id vmail
uid=666(vmail) gid=666(vmail) groups=666(vmail)
[root@westos-mail ~]# postconf -d | grep virtual
[root@westos-mail ~]# postconf -e "virtual_mailbox_base = /home/vmail"
[root@westos-mail ~]# postconf -e "virtual_uid_maps = static:666"
[root@westos-mail ~]# postconf -e "virtual_gid_maps = static:666"
[root@westos-mail ~]# postconf -e "virtual_alias_maps = mysql:/etc/postfix/mailuser.cf"
[root@westos-mail ~]# postconf -e "virtual_mailbox_maps = mysql:/etc/postfix/mailbox.cf"
[root@westos-mail ~]# postconf -e "virtual_mailbox_domain = mysql:/etc/postfi/maildomain.cf"
systemctl restart postfix.service
測試
給lee@lee.com的郵件在/home/vmail/lee.com/new/里面可以找到
附圖
網(wǎng)站標題:postfix
當(dāng)前地址:http://muchs.cn/article2/iiodoc.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供企業(yè)建站、品牌網(wǎng)站設(shè)計、靜態(tài)網(wǎng)站、用戶體驗、電子商務(wù)、外貿(mào)網(wǎng)站建設(shè)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)