前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >postfix+dns+dovecot+openwebmail

postfix+dns+dovecot+openwebmail

作者头像
知识浅谈
发布2020-03-24 16:05:16
1K0
发布2020-03-24 16:05:16
举报
文章被收录于专栏:分享学习分享学习

一:搭建DNS服务器 二:搭建postfix服务器及普通发信 三:普通收信 四:认证收信 五:squirrelmail收发邮件(搭建网页收发邮件)

dns 搭建:查考我的另一个博客https://blog.csdn.net/qq_37699336/article/details/80180853

第二部分:搭建postfix并配置基本发信功能 [root@localhost ~]# postconf –a //验证是否支持cyrus dovecot功能

这里写图片描述
这里写图片描述

(若postfix已安装好,则会支持这两个功能,若不支持,表示postfix未安装好;CentOS 7开始默认系统自带postfix。) ------------编辑主配置文件-------------- [root@localhost ~]# vi /etc/postfix/main.cf myhostname = mail.cyl.cn //邮件服务器的主机名 mydomain = cyl.cn //邮件域 myorigin = $mydomain //往外发邮件的邮件域 inet_interfaces = 192.168.0.2, 127.0.0.1 //监听的网卡 (注意,两个地址之间有空格) mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain home_mailbox = Maildir/ //邮件存放的目录

保存退出 [root@localhost ~]# postfix check //检查语法错误(与named-check用法一样)更改默认MTA为Postfix: /usr/sbin/alternatives --set mta /usr/sbin/sendmail.postfix 完事儿,再次检查下是否将MTA改为Postfix了: alternatives --display mta [root@localhost ~]# systemctl restart postfix //重启服务 [root@localhost ~]# postconf –n //查看postfix的非默认并已生效配置 -------------增加邮件测试帐号-------------- [root@localhost ~]# groupadd mailusers //创建组给测试帐号 [root@localhost ~]# useradd -g mailusers -s /sbin/nologin jack //创建jack帐户只属于mailusers组并不能登录系统,用于测试邮件 [root@localhost ~]# passwd jack //创建jack密码 [root@localhost ~]# useradd -g mailusers -s /sbin/nologin tom [root@localhost ~]# passwd tom --------------连接服务器的25端口进行简单发信测试----------- [root@localhost ~]# telnet mail.cyl.cn 25 //连接成功,开始写信 helo mail.cyl.cn //声明本机的主机 mail from:jack@cyl.cn //声明发件人地址 rcpt to:tom@cyl.cn //声明收件人地址 data //写正文 i am jack!! . //正文结束标记 quit // 退出

这里写图片描述
这里写图片描述

cd /home/tom/Maildir/new/ ls 查看对i应的文件

方法二:搭建dovecot提供收信服务 --------------安装dovecot软件---------------- [root@localhost ~]# yum install -y dovecot ---------------编辑配置文件-------------- [root@localhost ~]# vi /etc/dovecot/dovecot.conf //如果有去掉注释没有加上 protocols = imap pop3 lmtp listen = , :: //后边的 :: 代表的是ipv6 !include conf.d/.conf !include conf.d/10-auth.conf 在最后加上 ssl = no disable_plaintext_auth = no mail_location = maildir:~/Maildir ----------------启动服务-------------- [root@localhost ~]# systemctl start dovecot [root@localhost ~]# netstat -anpt | grep dovecot tcp 0 0 0.0.0.0:110 0.0.0.0:* LISTEN 53455/doveco tcp 0 0 0.0.0.0:143 0.0.0.0:* LISTEN 53455/doveco tcp6 0 0 :::110 ::? LISTEN 53455/doveco tcp6 0 0 :::143 ::? LISTEN 53455/doveco

//110,143端口需要监听

---------------收信验证--------------- [root@localhost ~]# telnet mail.aa.com 110 user tom //收件人登录 pass 123 //邮箱密码 list //列表查看邮件 retr 1 //读取编号为1的邮件 quit //退出邮箱

vi /etc/postfix/main.cf mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain mynetworks = 0.0.0.0/0 //允许接收所有网段发来的邮件,根据情况自行修改 relay_domains =$mydestination 在最后增加 smtpd_banner = $myhostname ESMTP $mail_name ($mail_version) default_process_limit = 50 default_destination_concurrency_limit = 20 smtpd_sasl_auth_enable = yes smtpd_sasl_local_domain = $myhostname smtpd_sasl_application_name = smtpd broken_sasl_auth_clients = yes smtpd_recipient_restrictions = permit_mynetworks,permit_sasl_authenticated,reject_unauth_destination smtpd_client_restrictions = permit_sasl_authenticated 保存退出 service postfix restart

安装cyrus-sasl

# yum -y install cyrus-sasl chkconfig saslauthd on

vi /etc/sysconfig/saslauthd 修改 /etc/sysconfig/saslauthd # vim /etc/sysconfig/saslauthd # Directory in which to place saslauthd’s listening socket, pid file, and so # on. This directory must already exist. SOCKETDIR=/var/run/saslauthd # Mechanism to use when checking passwords. Run “saslauthd -v” to get a list # of which mechanism your installation was compiled with the ablity to use. MECH=shadow

修改 vi /etc/sasl2/smtpd.conf

pwcheck_method: saslauthd

mech_list: plain login 测试 saslauthd # service saslauthd restart # testsaslauthd -u tom -p ‘tom’ 0: OK “Success.”

openwebmail安装 # cd /etc/yum.repos.d # wget -q http://openwebmail.org/openwebmail/download/redhat/rpm/release/openwebmail.repo centos7安装openwebmail (yum install -y openwebmail 是centos6.5中的) FUCK,FUCK,FUCK,搞了(4个小时,操了个dj),头发掉了一半 cd /opt centos7中需要perl 和perl-suidperl 而且要配套 perl wget http://mirror.centos.org/centos/7/os/x86_64/Packages/perl-5.16.3-292.el7.x86_64.rpm rpm -ivh --force --nodeps perl-5.16.3-292.el7.x86_64.rpm

perl-suidperl wget http://mirror.centos.org/centos/6/os/x86_64/Packages/perl-suidperl-5.10.1-144.el6.x86_64.rpm rpm -ivh --force --nodeps perl-suidperl-5.10.1-144.el6.x86_64.rpm 配置openwebmail

# vi /var/www/cgi-bin/openwebmail/etc/openwebmail.conf

domainnames cyl.cn default_language zh_CN.GB2312 default_timeoffset +0800 default_iconset Cool3D.Chinese.Simplified auth_module auth_unix.pl mailspooldir /var/spool/mail ow_cgidir /var/www/cgi-bin/openwebmail ow_cgiurl /cgi-bin/openwebmail ow_htmldir /var/www/data/openwebmail ow_htmlurl /data/openwebmail logfile /var/log/openwebmail.log

#vi /var/www/cgi-bin/openwebmail/etc/defaults/openwebmail.conf domainnames cyl smtpserver 192.168.0.2 #smtpserver 127.0.0.1 (这个如果是再阿里云上的话因为是自己对自己的测试,所以用127.0.0.1而不是用外网地址39.107.116.193) authpop3_server 192.168.0.2 #authpop3_server 192.168.0.2 (这个如果是再阿里云上的话因为是自己对自己的测试,所以用127.0.0.1而不是用外网地址39.107.116.193) smtpport 25 smtpauth no

# cd /var/www/cgi-bin/openwebmail yum install -y libperl* yum install perl-Socket -y yum install perl-Digest -y yum install perl-Digest-MD5 yum install perl-Text-Iconv.x86_64 /唯一能说的就是慢慢找错吧 -----------------------两天才弄好所有错 # ./openwebmail-tool.pl --init perl-suidperl-5.8.8 (通过CentOS的yum功能直接安装,安装版本 5.8.8这个是和perl配套的,如果和perl版本不一致可能导致初始化openwebmail时找不到libperl.so,openwebmail的辅助软件,必须要有); #service httpd restart

打开浏览器

输入192.168.45.128/webmail (或者 mail.test.com/webmail,这个我只在128本机上通过,猜测其他机子连接应该修改其dns) 系统提示: ‘/var/www/cgi-bin/openwebmail/.openwebmail.pl’ must setuid to root

原来刚才执行perl /var/www/cgi-bin/openwebmail/misc/tools/wrapsuid/wrapsuid.pl /var/www/cgi-bin/openwebmail/后,所有openwebmail*.pl文件的s位没有了。所以 chmod 4755 /var/www/cgi-bin/openwebmail/openwebmail*.pl 访问: http://localhost/cgi-bin/openwebmail/openwebmail.pl OK,可以看到登陆框了,说明openwebmail已经安装成功了,下面就是来结合sendmail了。

这里写图片描述
这里写图片描述
这里写图片描述
这里写图片描述
这里写图片描述
这里写图片描述
这里写图片描述
这里写图片描述

收信的时候

这里写图片描述
这里写图片描述
这里写图片描述
这里写图片描述
这里写图片描述
这里写图片描述

可能出现问题:

如果出现了下面的问题 Couldn’t create File /var/log/openwebmail.log! (Permission denied)

在网上找到解决办法了:如下方面 运行:

#touch /var/log/openwebmail.log

#chcon -u system_u /var/log/openwebmail.log #chcon -t httpd_sys_script_rw_t /var/log/openwebmail.log

#chcon -t httpd_unconfined_script_exec_t /var/www/cgi-bin/openwebmail/openwebmail*

我还遇到了一个问题,记不清了。大概是不能在/var/spool下面创建mai文件夹,解决方法是用root权限自己建立一个

全文借鉴网站 https://blog.csdn.net/kirao/article/details/3519683 中间遇到的 Requires: perl-suidperl Removing: 3:perl-suidperl-5.8.1-92.i386 (installed) perl-suidperl = 3:5.8.1-92 Obsoleted By: 4:perl-5.16.3-292.el7.x86_64 (base)

rpm包 强制卸载:rpm -e –nodeps xxxxxx.rpm

强制安装:rpm -ivh –nodeps xxxxxx.rpm

openwebmail的配置 http://cache.baiducontent.com/c?m=9f65cb4a8c8507ed19fa950d100b92235c438014628c8c52358fc51984642c101a39fec57c7e574ecec57e6402b8492ae8f72b73300820b58cc8ff109be4866d72c8713b2e47da0658c418dfdc3021d656924de8df0e97bde74395b9d2a28216049616522adfa3d004&p=c639d41086cc42ad589fc7710f488d&newp=cb759a46d4c308e90be296365b51bb231610db2151d6d0116b82c825d7331b001c3bbfb423251407d6c67d600aa84356effb35703d0923a3dda5c91d9fb4c57479c161&user=baidu&fm=sc&query=linux%D6%D0%B5%C4+openwebmail&qid=c24970630001f5a8&p1=3

找错最好文章 https://www.cnblogs.com/wwufengg/articles/openwebmail-error.html

本文参与?腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客?前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与?腾讯云自媒体同步曝光计划? ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档
http://www.vxiaotou.com