一、postfix操作:
前提:卸载sendmail:yum remove sendmail*
安装:yum -y install postfix*
1、rpm -ql postfix|more //可以查看postfix安装在哪
2、cp main.cf main.cf.bak
3、vi /etc/postfix/main.cf //配置main.cf
(1)、修改主机名
(2)、修改域名
(3)、修改myorigin(@后面的东西)
(4)、修改smtp监听的端口
(5)、修改inet_protocol(网络协议)
(6)、修改mydestination
(7)、设置信任的用户端
(8)、设定relay_domain转发邮件域名
(9)、设定邮件别名的路径
默认开启,不需要改。
4、重启postfix服务
(1)、systemctl restart network
(2)、systemctl restart saslauthd
二、Linux系统创建用户方法
1、删除用户的操作 userdel -r 用户名
2、创建用户的操作
useradd test;echo 123456|passwd --stdin test
3、创建邮箱
mkdir -p /home/test/mail/.imap/INBOX/
4、给权限
chown -R test.test /home/test/
5、检查postfix配置
postfix check
三、DNS域名映射
四、dovecot设置
1、查看saslauthd是否安装
2、安装dovecot
yum install dovecot* -y
3、编辑dovecot
(1)、vi /etc/dovecot/dovecot.conf
调整protocols和listen
(2)、vi /etc/dovecot/conf.d/10-auth.conf
(3)、vi /etc/dovecot/conf.d/10-mail.conf
(4)、vi /etc/dovecot/conf.d/10-ssl.conf
4、设置devocot开机自启,查看状态
systemctl start dovecot
systemctl enable dovecot
systemctl status dovecot
5、重启
(1)、systemctl restart network
(2)、 systemctl restart saslauthd
(3)、systemctl restart dovecot
systemctl restart network
systemctl restart saslauthd
systemctl restart dovecot
五、防火墙设置
1、查看防火墙状态:
systemctl status firewalld.service
2、临时关闭防火墙:
systemctl stop firewalld.service
3、永久关闭防火墙
systemctl disable firewalld.service
六、修改主机名
1、vi /etc/hosts
2、vi /etc/sysconfig/network
3、vi /etc/hostname
日志:tail -fn 100 /var/log/maillog
出现错误:imap(user): Error: chown(/home/user/mail/.imap/INBOX, group=12(mail)) failed: Operation not permitted (egid=1000(user), group based on /var/mail/user - see http://wiki2.dovecot.org/Errors/ChgrpNoPerm)
解决办法:
chmod 0600 /var/mail/*
systemctl restart network
systemctl restart saslauthd
systemctl restart dovecot
七、发送查看邮件
1、安装mailx
yum install -y mailx
2、查看邮件的发送状态:
systemctl status postfix -l
3、发送邮件
echo "this 22" | mail -s 'test' 2637554967@qq.co 'test'm
"this 22"是内容, 'test'是主题, 2637554967@qq.com是收件人
4、安装telnet
yum -y install telnet-server.x86_64
yum -y install telnet
5、查看Telnet的下载情况
rpm -qa |grep telnet
7、查看收件信息
telnet mail.caoguangyao.top 110
红框部分为域名
下图中,红框表示用户, 自己输入user 用户名(user和用户名中间有一个空格);黄框表示密码, 自己输入pass 密码(pass和密码中间有一个空格);蓝框列举收件的信息;top为打开信息,具体打开方法请参照下下图;退出Telnet指令,先输入.,在按回车就进入命令行,在命令行中输入quit。
八、postfixadmin
1、安装PHP yum源
(1)、yum install epel-release -y
(2)、rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
2、清理旧PHP
yum -y remove php*
3、查看可安装的版本
yum list php*
4、安装PHP