############################
####### postfix #######
############################
·准备
1.
postfix提供smtp协议用来投递邮件
默认端口25
/var/log/maillog##服务日志
mail root@westos.com
Subject: hello
hello world
.#用"."来结束录入内容并发送
mailq##查看邮件队列
postqueue -f##重新处理邮件队列
默认情况下邮件端口只在127.0.0.1上开启
2.
配置
vim /etc/postfix/main.cf
116 inet_interfaces = all##25端口开启的网络接口
76 myhostname = westos-mail.westos.com##指定mta主机名称
83 mydomain = westos.com##指定mta的域名
99 myorigin = westos.com##指定邮件来源结尾(@后面的字符内容)
164 mydestination = $myhostname, $mydomain, localhost##接收邮件结尾字符的指定
systemctl restart postfix.service
systemctl stop firewalld
3.邮件别名
[root@qq-mail ~]# vim /etc/aliases
别名:真名##邮件别名
别名::include:filename##邮件群发
vim filename
user1
user2
postalias /etc/aliases
mail 别名
4.通过远程主机测试邮件服务
[kiosk@foundation0 Desktop]$ telnet 172.25.254.100 25
Trying 172.25.254.100...
Connected to 172.25.254.100.
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>
adsf
asdf
asdf
.
5.邮件客户端的访问控制
#限制客户端
在mta上
postconf -e "smtpd_client_restrictions = check_client_access hash:/etc/postfix/access"
vim /etc/postfix/access
172.25.254.22REJECT
postmap /etc/postfix/access
systemctl restart postfix
测试
[root@foundation22 ~]# telnet 172.25.254.100 25
Trying 172.25.254.100...
Connected to 172.25.254.100.
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.22]>: Client host rejected: Access denied
##限制用户发送
postconf -e "smtpd_sender_restrictions = check_sender_access hash:/etc/postfix/sender"
vim /etc/postfix/sender
student@westos.comREJECT
postmap /etc/postfix/sender
systemctl restart postfix
测试
[kiosk@foundation0 Desktop]$ telnet 172.25.254.100 25
Trying 172.25.254.100...
Connected to 172.25.254.100.
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
##限制用户接收
postconf -e "smtpd_recipient_restrictions = check_recipient_access hash:/etc/postfix/recip"
vim /etc/postfix/recip
westos@westos.comREJECT
postmap /etc/postfix/recip
systemctl restart postfix
测试
[kiosk@foundation0 Desktop]$ telnet 172.25.254.100 25
Trying 172.25.254.100...
Connected to 172.25.254.100.
Escape character is ‘^]‘.
220 westos-mail.westos.com ESMTP Postfix
mail from:westos@westos.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>
adsf
adsf
asdf
.
250 2.0.0 Ok: queued as DE17D2461EA
qiut
502 5.5.2 Error: command not recognized
mail from:root@westos.com
250 2.1.0 Ok
rcpt to:westos@westos.com
554 5.7.1 <westos@westos.com>: Recipient address rejected: Access denied
##出站地址伪装
postconf -e "smtp_generic_maps = hash:/etc/postfix/generic"
vim /etc/postfix/generic
westos@westos.comhello@sb.com
postmap /etc/postfix/generic
systemctl restart postfix
测试
su - westos
mail root@qq.com
##入战地址转换
dns mx 记录解析先做好
postconf -e "virtual_alias_maps = hash:/etc/postfix/virtual"
/etc/postfix/virtual
虚拟名字真实用户
hello@sb.comwestos@westos.com
postmap /etc/postfix/virtual
systectl restart postfix
测试
mail hello@sb.com
####################################
######### dovecot ###############
####################################
1.
dovecot 用来提供收件协议
pop3 110
imap 143
pop3s 995
imaps 993
/etc/services ###所有服务的所有端口
2.
yum install dovecot y
3.
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-mail.conf
30 mail_location = mbox:~/mail:INBOX=/var/mail/%u
systemctl restart dovecot
mkdir /etc/skel/mail/.imap -p ###在用户骨架文件中建立所需目录及文件
touch /etc/skel/mail/.imap/INBOX
useradd westos
passwd westos
测试
yum install mutt -y
mutt -f pop://westos@172.25.254.116
###################
thunderbrid
####################
thunderbird
收发邮件应用
#########################
postfix + mariadb
#########################
准备工作
yum install httpd php php-mysql mariadb-server -y
config mariadb
mysql_secure_installation
create databs
create table
1.
vim /etc/postfix/mailuser.cf ##用户名称查询
host = localhost##数据库所在主机
user = postuser##登陆数据库的用户
password = 123##登陆数据库的密码
dbname = email##postfix要查询的名称
table = emailuser##postfix要查询的表的名称
select_field = username##postfix要查询的字段
where_field = username##用户给定postfix的查询条件
vim /etc/postfix/maildomain.cf ##用户域名查询
host = localhost
user = postuser
password = 123
dbname = email
table = emailuser
select_field = domain
where_field = domain
vim /etc/postfix/mailbox.cf ##用户邮箱位置查询
host = localhost
user = postuser
password = 123
dbname = email
table = emailuser
select_field = maildir
where_field = username
postmap -q "mmm@mmm.com" mysql:/etc/postfix/mailuser.cf
mmm@mmm.com
postmap -q "mmm.com" mysql:/etc/postfix/maildomain.cf
mmm.com
postmap -q "mmm@mmm.com" mysql:/etc/postfix/mailbox.cf
/mnt/mmm.com/mmm
配置postfix
groupadd -g 666 vmail
useradd -s /sbin/nologin -u 666 -g 666 vmail
postconf -e "virtual_mailbox_base = /home/vmail"##设定虚拟账户的邮件目录
postconf -e "virtual_uid_maps = static:666"##虚拟账户建立文件的uid
postconf -e "virtual_gid_maps = static:666"##虚拟用户建立文件的gid
postconf -e "virtual_alias_maps = mysql:/etc/postfix/mailuser.cf"
postconf -e "virtual_mailbox_domains = mysql:/etc/postfix/maildomain.cf"
postconf -e "virtual_mailbox_maps = mysql:/etc/postfix/mailbox.cf"
原文地址:http://12774035.blog.51cto.com/12764035/1929165