来源:互联网 发布:linux 查看raid卡型号 编辑:程序博客网 时间:2024/04/30 05:48
## mail ##
1.配置dns
[root@mailwestos named]# yum install bind -y //安装dns软件
[root@mailwestos named]# vim /etc/named.conf
...
options {
listen-on port 53 { any; }; *
listen-on-v6 port 53 { ::1; };
directory "/var/named";
dump-file "/var/named/data/cache_dump.db";
statistics-file "/var/named/data/named_stats.txt";
memstatistics-file "/var/named/data/named_mem_stats.txt";
allow-query { any; }; *
...
[root@mailwestos named]# vim /etc/named.rfc1912.zones
...
zone "westos.com" IN {
type master;
file "westos.com.zone";
allow-update { none; };
};
zone "linux.com" IN {
type master;
file "linux.com.zone";
allow-update { none; };
};
...
[root@mailwestos /]# cd /var/named/
[root@mailwestos named]# cp named.localhost westos.com.zone -p
[root@mailwestos named]# vim westos.com.zone
...
$TTL 1D
@ IN SOA dns.westos.com. root.westos.com. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS dns.westos.com.
dns A 172.25.254.104
westos.com. MX 1 172.25.254.104.
...
[root@mailwestos named]# cp named.localhost linux.com.zone -p
[root@mailwestos named]# vim linux.com.zone
...
$TTL 1D
@ IN SOA dns.linux.com. root.linux.com. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS dns.linux.com.
dns A 172.25.254.104
linux.com. MX 1 172.25.254.204.
...
[root@mailwestos named]# systemctl stop firewalld
测试端:
[root@maillinux ~]# vim /etc/resolv.conf
nameserver 172.25.254.104 *
[root@maillinux ~]# dig -t mx westos.com
; <<>> DiG 9.9.4-RedHat-9.9.4-14.el7 <<>> -t mx westos.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 56422
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 2
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;westos.com. IN MX
;; ANSWER SECTION:
westos.com. 86400 IN MX 1 172.25.254.104.
;; AUTHORITY SECTION:
westos.com. 86400 IN NS dns.westos.com.
;; ADDITIONAL SECTION:
dns.westos.com. 86400 IN A 172.25.254.104
;; Query time: 0 msec
;; SERVER: 172.25.254.104#53(172.25.254.104)
;; WHEN: Fri Mar 10 21:48:20 EST 2017
;; MSG SIZE rcvd: 103
2.配置服务器邮箱互发:
A方:
[root@mailwestos named]# vim /etc/postfix/main.cf
...
76 myhostname = mailwestos.westos.com //主机名
84 mydomain = westos.com //域名
100 myorigin = $mydomain //root@域名,发送方可见
114 inet_interfaces = all //允许所有端口
117 #inet_interfaces = localhost //注释调只允许本地访问
165 mydestination = $myhostname,$mydomain, localhost //接受地址
...
[root@mailwestos named]# systemctl restart postfix.service
B方:
[root@maillinux named]# vim /etc/postfix/main.cf
...
76 myhostname = linuxwestos.westos.com //主机名
84 mydomain = linux.com //域名
100 myorigin = $mydomain //root@域名,发送方可见
114 inet_interfaces = all //允许所有端口
117 #inet_interfaces = localhost //注释调只允许本地访问
165 mydestination = $myhostname,$mydomain, localhost //接受地址
...
[root@maillinux named]# systemctl restart postfix.service
**双方都需要关闭火墙**
3.postfix详细配置:
(常用命令)
postqueue -f 清空队列
postsuper -d 编号 删除指定编号队列
postconf -d 查看默认设置
postconf -n 查看当前设置
postconf -e "inet_interfaces = all" 修改选项
修改发送用户
[root@mailwestos named]# vim /etc/aliases
...
admin: root //用假的admin用户,表示root用户,root用户不变。
more: :include:/etc/postfix/users //多用户发送,用户名单在指定文件中。
[root@mailwestos named]# postalias /etc/aliases //加密/etc/aliases ,修改一次加密一次。
[root@mailwestos named]# vim /etc/postfix/users
root
student
测试:
mail admin@westos.com //不仅在本机适用,远程发送也可以用代表用户发送。
mail more //多用户发送;
空壳用户:
(另一台主机)
[root@maillinux ~]# vim /etc/postfix/virtual
...
admin@qq.com root@linux.com //空壳用户
@qq.com @linux.com //空壳域名
[root@maillinux ~]# postmap /etc/postfix/virtual //加密,每次修改都需要加密。
[root@maillinux ~]# postconf -d |grep virtual //查看virtual默认设置
[root@maillinux ~]# postconf -e "virtual_alias_maps = hash:/etc/postfix/virtual" //通过哈希加密方式访问加密文件
[root@maillinux ~]# postmap /etc/postfix/virtual
[root@maillinux ~]# systemctl restart postfix.service
测试:
mail admin@qq.com //空壳用户测试
mail student@qq.com //空壳域名测试
修改发送地址:
[root@maillinux ~]# vim /etc/postfix/generic
...
root@linux.com admin@qq.com
[root@maillinux ~]# postmap /etc/postfix/generic
[root@maillinux ~]postconf -e "smtp_generic_maps = hash:/etc/postfix/generic"
[root@maillinux ~]# postmap /etc/postfix/generic
[root@maillinux ~]# systemctl restart postfix.service
测试:
发送端
mail root@westos.com
接受端
[root@mailwestos named]# mail
Heirloom Mail version 12.5 7/5/10. Type ? for help.
"/var/spool/mail/root": 2 messages 1 new
1 root Sat Mar 11 23:23 22/748 "444"
>N 2 root Sat Mar 11 23:25 21/731 "555"
& 2
Message 2:
From admin@qq.com Sat Mar 11 23:25:13 2017
Return-Path: <admin@qq.com>
X-Original-To: root@westos.com
Delivered-To: root@westos.com
Date: Sat, 11 Mar 2017 23:25:12 +0800
To: root@westos.com
Subject: 555
User-Agent: Heirloom mailx 12.5 7/5/10
Content-Type: text/plain; charset=us-ascii
From: admin@qq.com (root)
Status: R
444
4.远程控制邮件的发送和接受
发送配置:
[root@foundation4 Desktop]# yum install telnet -y
[root@foundation4 Desktop]# telnet 172.25.254.204 25 //远程控制204给104发
Trying 172.25.254.204...
Connected to 172.25.254.204.
Escape character is '^]'.
220 maillinux.linux.com ESMTP Postfix
ehlo hello
250-maillinux.linux.com
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
mail from:root@qq.com
250 2.1.0 Ok
rcpt to:root@westos.com
250 2.1.5 Ok
data
354 End data with <CR><LF>.<CR><LF>
aaa
bbb
ccc
.
250 2.0.0 Ok: queued as D0ADB24252BF
quit
结果:
[root@mailwestos named]# mail
Heirloom Mail version 12.5 7/5/10. Type ? for help.
"/var/spool/mail/root": 3 messages 1 new
1 root Sat Mar 11 23:23 22/748 "444"
2 root Sat Mar 11 23:25 22/742 "555"
>N 3 root@qq.com Sat Mar 11 23:38 15/501
& 3
Message 3:
From root@qq.com Sat Mar 11 23:38:25 2017
Return-Path: <root@qq.com>
X-Original-To: root@westos.com
Delivered-To: root@westos.com
Status: R
aaa
bbb
ccc
& q
接受配置:
允许接受服务配置(只能是非root用户)
[root@maillinux ~]# yum install dovecot -y
[root@maillinux ~]# systemctl restart dovecot.service
[root@maillinux ~]# 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@maillinux ~]# vim 10-mail.conf
...
30 mail_location = mbox:~/mail:INBOX=/var/mail/%u
...
接受方
[root@foundation4 conf.d]# yum install mutt -y
[root@foundation4 conf.d]# mutt -f pop://student@172.25.254.204
注意还需要在接受服务的主机上,进入非root用上,并且执行
[student@maillinux ~]$ mkdir mail
[student@maillinux mail]$ mkdir .imap
[student@maillinux mail]$ touch /home/student/mail/.imap/INBOX
然后重新执行
[root@foundation4 conf.d]# mutt -f pop://student@172.25.254.204
(已经存在的用户,且没有要求文件)
新建立的可以使用:
[root@maillinux ~]# cd /etc/skel/
[root@maillinux skel]# mkdir mail
[root@maillinux skel]# cd mail/
[root@maillinux mail]# mkdir .imap
[root@maillinux mail]# touch .imap/INBOX
建立用户时默认创建
5.使用客户端查看邮件
[root@foundation4 Desktop]# vim /etc/resolv.conf
nameserver 172.25.254.104
...
[root@foundation4 Desktop]# thunderbird
照步骤执行
6.postfix-mysql
A.给mysql数据库用户发邮件.
postfix + httpd + php + mysql + stmp
[root@maillinux skel]# yum install mariadb-server httpd php php-mysql -y
[root@maillinux skel]# vim /etc/my.cnf
...
skip-network= 1 //跳过网络访问
...
[root@maillinux skel]# systemctl restart mariadb.service
[root@maillinux skel]# mysql_secure_installation //设置密码lee
[root@maillinux skel]# cd /var/www/html/
[root@maillinux html]# ls
phpMyAdmin-3.4.0-all-languages.tar.bz2
[root@maillinux html]# tar jxf phpMyAdmin-3.4.0-all-languages.tar.bz2
[root@maillinux html]# ls
phpMyAdmin-3.4.0-all-languages phpMyAdmin-3.4.0-all-languages.tar.bz2
[root@maillinux html]# rm -fr phpMyAdmin-3.4.0-all-languages.tar.bz2
[root@maillinux html]# mv phpMyAdmin-3.4.0-all-languages/ myadmin
[root@maillinux html]# cd myadmin/
[root@maillinux myadmin]# cp config.sample.inc.php config.inc.php
[root@maillinux myadmin]# vim config.inc.php
$cfg['blowfish_secret'] = 'dasdsa'; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */
...
关闭火墙,用firefox访问172.25.254.204/myadmin
[root@maillinux ~]# cd /etc/postfix/
[root@maillinux postfix]# vim mysql-user.cf
hosts = localhost
user = postfix
password = postfix
dbname = email
table = mailuser
select_field = username
where_field = username
[root@maillinux postfix]# mysql -uroot -plee -e "select username from email.mailuser;"
+------------------+
| username |
+------------------+
| admin@redhat.com |
| westos@luck.com |
+------------------+
[root@maillinux postfix]# vim mysql-user.cf
hosts = localhost
user = postfix
password = postfix
dbname = email
table = mailuser
select_field = username
where_field = username
[root@maillinux postfix]# vim mysql-mailbox.cf
hosts = localhost
user = postfix
password = postfix
dbname = email
table = mailuser
select_field = maildir
where_field = username
检验:
[root@maillinux postfix]# postmap -q "admin@redhat.com" mysql:/etc/postfix/mysql-user.cf
admin@redhat.com
[root@maillinux postfix]# postmap -q "admin@redhat.com" mysql:/etc/postfix/mysql-mailbox.cf
/redhat.com/admin/
[root@maillinux postfix]# postmap -q "redhat.com" mysql:/etc/postfix/mysql-domain.cf
redhat.com
[root@maillinux postfix]# groupadd -g 888 vmail
[root@maillinux postfix]# useradd -u 888 vmail
[root@maillinux postfix]# id 888
uid=888(vmail) gid=888(vmail) groups=888(vmail)
[root@maillinux postfix]# id vmail
uid=888(vmail) gid=888(vmail) groups=888(vmail)
[root@maillinux postfix]# postconf -e "virtual_mailbox_base = /home/vmail"
[root@maillinux postfix]# postconf -e "virtual_gid_maps = static:888"
[root@maillinux postfix]# postconf -e "virtual_uid_maps = static:888"
[root@maillinux postfix]# postconf -e "virtual_alias_maps = mysql:/etc/postfix/mysql-user.cf"
[root@maillinux postfix]# postconf -e "virtual_mailbox_domains = mysql:/etc/postfix/mysql-domain.cf"
[root@maillinux postfix]# postconf -e "virtual_mailbox_maps = mysql:/etc/postfix/mysql-mailbox.cf"
[root@maillinux postfix]# vim /etc/postfix/main.cf
...
virtual_mailbox_base = /home/vmail
virtual_gid_maps = static:888
virtual_uid_maps = static:888
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-mailbox.cf
...
测试:
[root@maillinux postfix]# mail westos@luck.com
Subject: 111
aaa
.
EOT
[root@maillinux postfix]# mail admin@redhat.com
Subject: 222
abc
.
EOT
[root@maillinux postfix]# cd /home/
[root@maillinux home]# ls
student vmail
[root@maillinux home]# cd vmail/
[root@maillinux vmail]# ls
luck.com redhat.com
[root@maillinux vmail]# cd redhat.com/
[root@maillinux redhat.com]# ls
admin
[root@maillinux redhat.com]# cd admin/
[root@maillinux admin]# ls
cur new tmp //new->未读的 cur->已经读取的 tmp->临时的
B.接受邮件
postfix + httpd + php + mysql + dovecot
[root@maillinux new]# vim /etc/dovecot/dovecot.conf
48 login_trusted_networks =0.0.0.0/0
49 disable_plaintext_auth=no
...
[root@maillinux new]# vim /etc/dovecot/conf.d/10-auth.conf
...
123 !include auth-sql.conf.ext
...
[root@maillinux new]# vim /etc/dovecot/dovecot-sql.conf.ext
31 # Database driver: mysql, pgsql, sqlite
32 driver = mysql
71 connect = host=localhost dbname=email user=postfix password=postfix
78 default_pass_scheme = PLAIN
107 password_query = \
108 SELECT username, domain, password \
109 FROM mailuser WHERE username = '%u' AND domain = '%d'
125 user_query = SELECT maildir, 888 AS uid, 888 AS gid FROM mailuser WHERE username = '%u'
[root@maillinux new]# vim /etc/dovecot/conf.d/10-mail.conf
# There are a few special variables you can use, eg.:
#
# # %u - username
# # %n - user part in user@domain, same as %u if there's no domain
# # %d - domain part in user@domain, empty if there's no domain
# # %h - home directory
#
mail_location = maildir:/home/vmail/%d/%n
...
[root@maillinux new]# yum install dovecot-mysql -y
[root@maillinux dovecot]# systemctl restart dovecot.service
测试:
[root@foundation4 Desktop]# telnet 172.25.254.204 110
Trying 172.25.254.204...
Connected to 172.25.254.204.
Escape character is '^]'.
+OK [XCLIENT] Dovecot ready.
user admin@redhat.com
+OK
pass 123
+OK Logged in.
- Mail服务器
- mail sample
- Google Mail
- send Mail
- test mail
- stmp mail
- js出现undefind的情况需要注意的几个问题
- 输入框限制只能读
- 虚拟机安装red hat后为什么不能联网?
- 逻辑与,逻辑或的使用
- 简单工厂模式、单例模式以及MVC模式
- 51nod 1009 数字1的数量
- 【整理】C++ string转int,string转double,string转long,int转string,double转string…
- 网易新闻API接口的实现(Picasso类库的使用与HTTP协议的get请求,BitMap样例(未使用))
- 解决RecyclerView加载图片时复用itemview导致的图片数量错乱问题
- 莫让奔波收效甚微
- Java中对Redis的缓存
- K-SUM
- 欢迎使用CSDN-markdown编辑器