postfix CentOS 7.0
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了postfix CentOS 7.0相关的知识,希望对你有一定的参考价值。
postconf -a // 验证是否支持cyrus dovecot功能
service postfix start //启动服务
netstat -anpt | grep 25 //SMTP 端口号
service postfix status //查看服务是否启动
[[email protected] ~]# vi /etc/named.conf
options {
listen-on port 53 { 192.168.80.80; }; //改成服务器网址
allow-query { any; };
[[email protected] ~]# vi /etc/named.rfc1912.zones
zone "aa.com" IN { // 设邮件地址
type master;
file "aa.com.zone";
};
zone "80.168.192.in-addr.arpa" {
type master;
file "aa.com.local";
};
[[email protected] ~]# cd /var/named/
[[email protected] named]# ls
data dynamic named.ca named.empty named.localhost named.loopback slaves
[[email protected] named]# cp -p named.localhost aa.com.zone
[[email protected] named]# vi aa.com.zone
NS mail.aa.com.
MX 10 mail.aa.com.
mail A 192.168.80.189
[[email protected] named]# cp -p aa.com.zone aa.com.local
[[email protected] named]# vi aa.com.local
$TTL 1D
@ IN SOA aa.com. rname.invalid. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS mail.aa.com.
MX 10 mail.aa.com.
189 PTR mail.aa.com.
[[email protected] named]# service named start
Redirecting to /bin/systemctl start named.service
[[email protected] named]# systemctl enable named
[[email protected] named]# vi /etc/resolv.conf
nameserver 192.168.80.189
[[email protected] named]# yum provides nslookup
[[email protected] named]# nslookup mail.aa.com
[[email protected] named]# vi /etc/postfix/main.cf
vi /etc/postfix/main.cf
myhostname = mail.aa.com
mydomain = aa.com
myorigin = $mydomain
inet_interfaces = 192.168.80.181, 127.0.0.1
inet_protocols = ipv4
mydestination = $myhostname, $mydomain
home_mailbox = Maildir/
[[email protected] named]# postfix check
[[email protected] named]# service postfix reload
[[email protected] named]# postfix -n
-----增加邮件测试账号-------
groupadd mailusers
useradd -g mailusers -s /sbin/nologin jack
passwd jack
useradd -g mailusers -s /sbin/nologin tom
passwd tom
yum install telnet
[[email protected] named]# telnet mail.aa.com 25
telnet: connect to address 192.168.80.80: Connection refused //查看防火墙(service firewalld status 和 service postfix restart)
Trying 192.168.80.80...
Connected to mail.aa.com.
Escape character is ‘^]‘.
220 mail.aa.com ESMTP Postfix
helo mail.aa.com
250 mail.aa.com
mail from:[email protected]
250 2.1.0 Ok
rcpt to:[email protected]
250 2.1.5 Ok
data
354 End data with <CR><LF>.<CR><LF>
i am jack
fuck
.
250 2.0.0 Ok: queued as CA48110AEE8A
quit
221 2.0.0 Bye
--使用root查看tom用户是否收到测试邮件----
cat /home/tom/Maildir/new/(1515928363.Vfd02I600041M10880
.localhost.localdomain = tap补齐)
------安装dovecot提供收信服务------
yum install dovecot
vi /etc/dovecot/dovecot.conf
protocols = imap pop3 lmtp 去掉注解#
!include conf.d/10-auth.conf
--以下手写--
ssl = no
disable_plaintext_auth = no
mail_location = maildir:~/Maildir
service dovecot start //启动服务
netstat -anpt | grep dovecot // 110 143端口需要监听
---以下测试收信----
telnet mail.aa.com 110
user tom
pass 123123
list
1 381
.
retr 1
quit
outlook 配置测试。
[email protected] //帐号
密码:123 // 设置帐号时增加密码
--------以下进行发信认证配置------
yum install cyrus-sasl* //关注
vi /etc/sasl2/smtpd.conf
pwcheck_method: saslauthd
mech_list: plain login
log_level:3
vi /etc/sysconfig/saslauthd
MECH=shadow
service saslauthd start
systemctl enable saslauthd
vi /etc/postfix/main.cf
--在末尾新增--
smtpd_sasl_auth_enable = yes //开启认证
smtpd_sasl_security_options = noanonymous //不允许匿名发信
mynetworks = 127.0.0.0/8 //允许的网段,如果增加本机所在网段就会出现允许不验证也能向外域发信
smtpd_recipient_restrictions = permit_mynetworks,permit_sasl_authenticated,reject_unauth_destination //允许本地域以及认证成功的发信,拒绝认证失败的发信
postfix check
service postfix reload
----测试普通发信-----
telnet mail.aa.com 25
helo mail.aa.com
mail from:[email protected]
rcpt to:[email protected] //提示:Relay access denied
quit
------测试认证发信,注意:一定要关闭SELINUX-----
---以下将用户名密码生成密文----
[[email protected] sasl2]# printf "jack" | openssl base64
amFjaw==
[[email protected] sasl2]# printf "123" | openssl base64
MTIz
----------以下是配置squirrelmail收发邮件----------------
注意:需要搭建好LAMP环境
--------RPM安装LAMP---------
yum install -y \
httpd \
mariadb-server mariadb \
php \
php-mysql \
php-gd \
libjpeg* \
php-ldap \
php-odbc \
php-pear \
php-xml \
php-xmlrpc \
php-mhash
vi /etc/httpd/conf/httpd.conf
ServerName www.aa.com
DirectoryIndex index.html index.php
vi /etc/php.ini
date.timezone = PRC
systemctl stop firewalld.service
setenforce 0
systemctl start httpd.service
systemctl start mariadb.service
netstat -anpt | grep 80
netstat -anpt | grep 3306
mysql_secure_installation
vi /var/www/html/index.php
<?php
phpinfo();
?>
http://192.168.80.80/ //服务器网址
--------进入数据库,建立授权账号-----
mysql -u root -p
CREATE DATABASE abc;
GRANT all ON abc.* TO ‘mail‘@‘%‘ IDENTIFIED BY ‘123456‘;
flush privileges;
--------下面测试数据库工作是否正常-----
<?php
$link=mysql_connect(‘192.168.80.181‘,‘mail‘,‘123456‘); //服务网址
if($link) echo "<h1>Success!!</h1>";
else echo "Fail!!";
mysql_close();
?>
------上传服务器压缩包
[[email protected] ~]# yum install vsftpd -y
[[email protected] ~]# vi /etc/vsftpd/vsftpd.conf
[[email protected] ~]# systemctl restart vsftpd
[[email protected] ~]# cd /var/ftp/
[[email protected] ftp]# ls
以上是关于postfix CentOS 7.0的主要内容,如果未能解决你的问题,请参考以下文章