Sendmail+dovecot+saslauth+rainloop

环境:CentOS 6.4(最小化安装)

关闭防火墙和selinux

Sendmail的配置文件

/etc/mail/sendmail.cf :Sendmail的主配置文件;

/etc/mail/access :中继访问控制;

/etc/mail/domaintable ;域名映射;

/etc/mail/local-host-names ;本地主机别名;

/etc/mail/mailertable :为特定的域指定特殊的路由规则;

/etc/mail/virtusertable :虚拟域配置

Sendmail为发送服务器

[[email protected] ~]# yum -y install sendmail sendmail-cf openssl-devel dovecot cyrus*
[[email protected] ~]# nslookup
> mail.com
Server: 192.168.100.243
Address:192.168.100.243#53
Name:mail.com
Address: 192.168.100.243
> 192.168.100.243
Server: 192.168.100.243
Address:192.168.100.243#53
243.100.168.192.in-addr.arpaname = com.
243.100.168.192.in-addr.arpaname = mail.com.
243.100.168.192.in-addr.arpaname = aa.com.
> exit
[[email protected] ~]#

或者

[[email protected] ~]# tail -1 /etc/hosts
192.168.100.243 mail.com mail mail.com.com localhost localhost.localdomain
[[email protected] ~]#
[[email protected] ~]# sed -i ‘/^\:OUTPUT ACCEPT/a\-A INPUT \-m state \-\-state NEW \-m tcp \-p tcp \-\-dport 25 \-j ACCEPT‘ /etc/sysconfig/iptables
[[email protected] ~]# sed -i ‘/^\:OUTPUT ACCEPT/a\-A INPUT \-m state \-\-state NEW \-m tcp \-p tcp \-\-dport 110 \-j ACCEPT‘ /etc/sysconfig/iptables
[[email protected] ~]# /etc/init.d/iptables restart
iptables: Flushing firewall rules:                         [  OK  ]
iptables: Setting chains to policy ACCEPT: filter          [  OK  ]
iptables: Unloading modules:                               [  OK  ]
iptables: Applying firewall rules:                         [  OK  ]
[[email protected] ~]# chkconfig iptables on
[[email protected] ~]# setenforce 0
[[email protected] ~]# /etc/init.d/postfix stop
Shutting down postfix:                                     [  OK  ]
[[email protected] ~]# chkconfig postfix off
[[email protected] ~]# echo ‘mail.com RELAY‘ >>/etc/mail/access
[[email protected] ~]# echo ‘192.168.100. RELAY‘ >>/etc/mail/access
[[email protected] ~]# sed -i "/confCACERT_PATH/s/^dnl//g" /etc/mail/sendmail.mc
[[email protected] ~]# sed -i "/confCACERT_PATH/s/^[ \t]//g" /etc/mail/sendmail.mc
[[email protected] ~]# sed -i "/ca-bundle.crt/s/^dnl//g" /etc/mail/sendmail.mc
[[email protected] ~]# sed -i "/ca-bundle.crt/s/^[ \t]//g" /etc/mail/sendmail.mc
[[email protected] ~]# sed -i "/confSERVER_CERT/s/^dnl//g" /etc/mail/sendmail.mc
[[email protected] ~]# sed -i "/confSERVER_CERT/s/^[ \t]//g" /etc/mail/sendmail.mc
[[email protected] ~]# sed -i "/confSERVER_KEY/s/^dnl//g" /etc/mail/sendmail.mc
[[email protected]host ~]# sed -i "/confSERVER_KEY/s/^[ \t]//g" /etc/mail/sendmail.mc
[[email protected] ~]# sed -i "/TRUST_AUTH_MECH/s/^dnl//g" /etc/mail/sendmail.mc
[[email protected] ~]# sed -i "/TRUST_AUTH_MECH/s/^[ \t]//g" /etc/mail/sendmail.mc
[[email protected] ~]# sed -i "/confAUTH_MECHANISMS/s/^dnl//g" /etc/mail/sendmail.mc
[[email protected] ~]# sed -i "/confAUTH_MECHANISMS/s/^[ \t]//g" /etc/mail/sendmail.mc
[[email protected] ~]# sed -i ‘/^DAEMON_OPTIONS/s/127\.0\.0\.1/0\.0\.0\.0/g‘ /etc/mail/sendmail.mc
[[email protected] ~]# sed -i ‘/UUCP_MAILER_MAX/s/2/4/g‘ /etc/mail/sendmail.mc      //限制附件的大小
[[email protected] ~]# cd /etc/mail/
[[email protected] mail]# m4 sendmail.mc > sendmail.cf

限制邮件的大小:

[[email protected] ~]# sed -i ‘/MaxMessageSize/s/^#//g‘ /etc/mail/sendmail.cf
[[email protected] ~]# sed -i ‘/MaxMessageSize/s/0/4000000/g‘ /etc/mail/sendmail.cf

配置DOVECOT:

[[email protected] ~]# sed -i ‘/protocols/s/^#//g‘ /etc/dovecot/dovecot.conf

如果不做下面的操作,会报:-ERR Plaintext authentication disallowed on non-secure (SSL/TLS) connections错误

[[email protected] ~]# sed -i ‘/login_trusted_networks/s/^#//g‘ /etc/dovecot/dovecot.conf
[[email protected] ~]# sed -i ‘/login_trusted_networks/s/\=/\= 0\.0\.0\.0\/0/g‘ /etc/dovecot/dovecot.conf
[[email protected] ~]# sed -i ‘/INBOX\=/s/^#//g‘ /etc/dovecot/conf.d/10-mail.conf
[[email protected] ~]# sed -i ‘/INBOX\=/s/^[ \t]*//g‘ /etc/dovecot/conf.d/10-mail.conf
[[email protected] ~]# echo ‘mail.com‘ >> /etc/mail/local-host-names
[[email protected] ~]# sed -i ‘/MECH\=/s/pam/shadow/‘ /etc/sysconfig/saslauthd
[[email protected] ~]# chkconfig sendmail on
[[email protected] ~]# chkconfig dovecot on
[[email protected] ~]# chkconfig saslauthd on
[[email protected] ~]# /etc/init.d/sendmail restart
[[email protected] ~]# /etc/init.d/dovecot restart
[[email protected] ~]# /etc/init.d/saslauthd restart

如果报-ERR [IN-USE] Couldn‘t open INBOX: Internal error occurred. Refer to server log for more information. 错误则

[[email protected] ~]$ mkdir -p /home/yfshare/mail/.imap/INBOX即可

在这里添加上即可(执行上面脚本也可):

[[email protected] ~]# tail -n 5 /etc/skel/.bashrc |head -n 3
if [ ! -d ~/mail/.imap/INBOX ];then
mkdir -p ~/mail/.imap/INBOX
fi
[[email protected] ~]#
[[email protected] ~]# useradd yfshare
[[email protected] ~]# useradd bob
[[email protected] ~]# useradd jerry
[[email protected] ~]# passwd yfshare
[[email protected] ~]# passwd bob
[[email protected] ~]# passwd jerry
[[email protected] ~]# echo -e "group1:\tyfshare,bob" >>/etc/aliases
[[email protected] ~]# newaliases
/etc/aliases: 77 aliases, longest 11 bytes, 782 bytes total
[[email protected] ~]# /etc/init.d/sendmail restart
Shutting down sm-client:                                   [  OK  ]
Shutting down sendmail:                                    [  OK  ]
Starting sendmail:                                         [  OK  ]
Starting sm-client:                                        [  OK  ]
[[email protected] ~]#
[[email protected] ~]# saslauthd -v                //查看是否支持pam或shadow
saslauthd 2.1.23
authentication mechanisms: getpwent kerberos5 pam rimap shadow ldap
[[email protected] ~]# testsaslauthd -u yfshare -p wang1024**
0: OK "Success."
[[email protected] ~]# testsaslauthd -u bob -p wang1024**
0: OK "Success."
[[email protected] ~]# testsaslauthd -u jerry -p wang1024**
0: OK "Success."
[[email protected] ~]#
如果显示0: OK “Success.”则表明saslauthd工作正常
[[email protected] ~]# mailq             //查看sendmail队列
/var/spool/mqueue is empty
  Total requests: 0
[[email protected] ~]#
[[email protected] ~]# mailstats        //查看邮件系统的状态
Statistics from Wed Sep  9 17:41:02 2015
 M   msgsfr  bytes_from   msgsto    bytes_to  msgsrej msgsdis msgsqur  Mailer
=====================================================================
 T        0          0K        0          0K        0       0       0
 C        0                    0                    0
[[email protected] ~]#

验证:

[[email protected] ~]# telnet mail.com 25
Trying 192.168.100.243...
Connected to mail.com.
Escape character is ‘^]‘.
220 aa.com ESMTP Sendmail 8.14.4/8.14.4; Thu, 10 Sep 2015 14:03:34 +0800
mail from:[email protected]
250 2.1.0 [email protected] Sender ok
rcpt to:[email protected]
250 2.1.5 [email protected] Recipient ok
data
354 Enter mail, end with "." on a line by itself
this is test mail~~~!!
.
250 2.0.0 t8A63Yf6002353 Message accepted for delivery
quit
221 2.0.0 aa.com closing connection
Connection closed by foreign host.
[[email protected] ~]#
[[email protected] ~]$ mail
Heirloom Mail version 12.4 7/29/08.  Type ? for help.
"/var/spool/mail/bob": 1 message
>   1 [email protected]      Thu Sep 10 14:05  13/471  
&

注:如果用IMAP来接收邮件,在邮件帐号里面直接写用户名,不加@mail.com

上面搭建的邮件服务器是使用明文传输的,不安全。

下面给邮件服务器弄个SSL:(dovecot默认就支持pop3s和imaps)


pop3


110


pop3s


995


smtp


25


smtps


465


imap


143

imaps
993

生成sendmail.pem文件

[[email protected] ~]# cd /etc/pki/tls/certs/
[[email protected] certs]# make sendmail.pem
[[email protected] ~]# head -n 63 /etc/mail/sendmail.mc |tail -n 4
define(`confCACERT_PATH‘, `/etc/pki/tls/certs‘)dnl
define(`confCACERT‘, `/etc/pki/tls/certs/ca-bundle.crt‘)dnl
define(`confSERVER_CERT‘, `/etc/pki/tls/certs/sendmail.pem‘)dnl
define(`confSERVER_KEY‘, `/etc/pki/tls/certs/sendmail.pem‘)dnl
[[email protected] ~]#

开启SMTPS:

[[email protected] ~]# sed -i ‘/TLSMTA/s/^dnl//g‘ /etc/mail/sendmail.mc
[[email protected] ~]# sed -i ‘/TLSMTA/s/^[ \t]*//g‘ /etc/mail/sendmail.mc
[[email protected] ~]# cd /etc/mail/
[[email protected] mail]# cp sendmail.cf sendmail.cf.bak
[[email protected] mail]# m4 sendmail.mc > sendmail.cf
[[email protected] ~]# yum -y install xinetd
[[email protected] ~]# /etc/init.d/xinetd restart
[[email protected] ~]# ll /etc/pki/tls/certs/sendmail.pem
-rw------- 1 root root 2913 Sep 10 11:45 /etc/pki/tls/certs/sendmail.pem
[[email protected] ~]#
[[email protected] ~]# /etc/init.d/sendmail restart
Shutting down sm-client:                                   [  OK  ]
Shutting down sendmail:                                    [  OK  ]
Starting sendmail:                                         [  OK  ]
Starting sm-client:                                        [  OK  ]
[[email protected] ~]#
[[email protected] ~]# /etc/init.d/dovecot restart
Stopping Dovecot Imap:                                     [  OK  ]
Starting Dovecot Imap:                                     [  OK  ]
[[email protected] ~]#
[[email protected] ~]# /etc/init.d/saslauthd restart
Stopping saslauthd:                                        [  OK  ]
Starting saslauthd:                                        [  OK  ]
[[email protected] ~]#
[[email protected] ~]# netstat -anp|grep dovecot|head -n 4
tcp        0      0 0.0.0.0:110                 0.0.0.0:*                   LISTEN      2642/dovecot        
tcp        0      0 0.0.0.0:143                 0.0.0.0:*                   LISTEN      2642/dovecot        
tcp        0      0 0.0.0.0:993                 0.0.0.0:*                   LISTEN      2642/dovecot        
tcp        0      0 0.0.0.0:995                 0.0.0.0:*                   LISTEN      2642/dovecot        
[[email protected] ~]#
[[email protected] ~]# netstat -anp|grep sendmail
tcp        0      0 0.0.0.0:465                 0.0.0.0:*                   LISTEN      2621/sendmail       
tcp        0      0 0.0.0.0:25                  0.0.0.0:*                   LISTEN      2621/sendmail       
unix  2      [ ]         DGRAM                    15538  2629/sendmail: Queu
unix  2      [ ]         DGRAM                    15523  2621/sendmail      
[[email protected] ~]#

测试成功:a/b/c三个用户,group包含a/b用户,c给a发送邮件并抄送给group,这时a只会收到一封邮件,Sendmail会过滤掉相同mailID的邮件。而Postfix则会给a发送两封一模一样的邮件

[[email protected] ~]# mailstats
Statistics from Thu Sep 10 14:05:06 2015
 M   msgsfr  bytes_from   msgsto    bytes_to  msgsrej msgsdis msgsqur  Mailer
 4        4         12K        0          0K        0       0       0  esmtp
 9       10         27K       16         40K        3       0       0  local
=====================================================================
 T       14         39K       16         40K        3       0       0
 C       16                    0                    3
[[email protected] ~]#

如果把这行注释掉,Sendmail就不支持smtp发送邮件了,只支持smtps发送邮件

安装rainloop:

[[email protected] ~]# yum -y install php*
[[email protected] ~]# unzip rainloop-latest.zip  -d /var/www/html/
[[email protected] ~]# chown apache:apache /var/www/html/* -R
[[email protected] ~]# sed -i ‘/^DirectoryIndex/s/html/html index.php/g‘ /etc/httpd/conf/httpd.conf
[[email protected] ~]# sed -i ‘/post_max_size/s/8/4/g‘ /etc/php.ini
[[email protected] ~]# sed -i ‘/upload_max_filesize/s/2/3/g‘ /etc/php.ini
[[email protected] ~]# /etc/init.d/httpd restart
Stopping httpd:                                            [  OK  ]
Starting httpd:                                            [  OK  ]
[[email protected] ~]# chkconfig httpd on

访问:http://192.168.100.243/?admin进入后台管理

不允许用户添加其他的账户

添加个性化标题:

访问:http://192.168.100.243进入web mail

如果出现无法载入邮件,把下面这个改成off,保存配置后再登录即可

[[email protected] ~]# grep autocreate_system_folders /var/www/html/data/_data_/_default_/configs/application.ini
autocreate_system_folders = On
[[email protected] ~]#

你应该知道的最好Webmail邮件客户端

Postfix+dovecot+saslauth

时间: 2024-08-05 10:39:09

Sendmail+dovecot+saslauth+rainloop的相关文章

Postfix+dovecot+saslauth

环境:Centos 6.4 关闭防火墙和selinux [[email protected] ~]# postconf mail_version mail_version = 2.6.6 [[email protected] ~]# [[email protected] ~]# yum -y install postfix dovecot cyrus* openssl openssl-devel [[email protected] ~]# sed -i '/host\.domain\.tld/

CentOS6 安装Sendmail + Dovecot + Squirrelmail

本文记录在本地虚拟机CentOS6上搭建Sendmail + Dovecot + Squirrelmail 的Webmail环境的过程,仅仅是本地局域网的环境测试,不配置DNS, 也没有安全认证,Squirrelmail 版本squirrelmail-webmail-1.4.22. 前言 关于CentOS系统的安装,这里便不做介绍了,大家可以在网上找到很多相关的资料参考.如果已经对下面的命令熟悉的朋友,请直接跳到下一步... 现简单介绍一下一些基本命令的使用: 1.查看系统发行版本 [[emai

CentOS6.5安装配置sendmail+dovecot

1.挂载光盘,rpm安装sendmail相关的软件包安装dovecot2.配置DNS服务正向解析反向解析3.修改主机名称4.进入/etc/mail,修改sendmail.mc文件m4 sendmail.mc >sendmail.cf5.修改/etc/mail/access文件6.修改/etc/mail/local-host-names文件7.配置/etc/dovecot/dovecot.conf文件8.修改/etc/dovecot/conf.d/10-mail.conf文件9.启动sendmai

kubuntu+roundcube搭建邮件服务器(包含LAMP)

好久之前写的了,偶然翻到然后拿出来看看,里面文字图片都没改,有错误请见谅 步骤: 一.关于ubuntu的安装二.ubuntu配置LAMP(Linux+Apache+Mysql+Perl/PHP/Python)三.Ubuntu+Sendmail+Dovecot+roundcubewebmail 写在前面: 1.网上多选用openwebmail作为webmail的例子来用(也是因为仿照鸟哥的原因居多)2.本文中选用了较为简单和大众化的roundcubewebmail3.本文中多数指令和教程来源于网络

Zabbix用Email介质SMTP发送报警

Zabbix报警大部分使用的是脚本报警,这次我们用SMTP方式发送报警. 在zabbix上设置好了EMail账号还不行,还要在系统里装发送邮件的服务,我们这里用SendMail. 环境: CentOS Linux release 7.1.1503 (Core) 1.检查系统是否安装SendMail. #rpm -qa | grep Sendmail 返回值为空,说明没有安装过. 2.用yum list sedmail看看都需要安装哪些包 #yum list sedmail 3.安装Sendmai

Linux下6种优秀的邮件传输代理

最好的Linux邮件传输代理(MTAs) 邮件传输代理(MTA)是什么? MTA是一个应用程序,该应用程序路由和传输电子邮件从一个节点到另一个网络,它使用一个被称为SMTP(简单邮件传输协议)的协议来执行其任务. 在网络节点上,存在一个电子邮件客户端,用于发送和接收消息的邮件服务器,电子邮件客户机也使得使用SMTP协议的,但未必是MTA. MTA被安装在邮件服务器上,和一些电子邮件客户端中,如(Mozilla Thunderbird)雷鸟,(Evolution),微软的Outlook和Apple

烂泥:ubuntu下配置msmtp+mutt发送邮件

本文由ilanniweb提供友情赞助,首发于烂泥行天下 想要获得更多的文章,可以关注我的微信ilanniweb. 本文主要介绍如何在Linux下使用msmtp+mutt发送邮件,当然Linux下发送邮件的工具很多,比如sendmail+dovecot等.但是它们的配置一般都比较复杂,因此我们来使用配置比较简单的msmtp+mutt组合来发送邮件. msmtp+mutt组合配置很简单,只需要几步就可以完成.下面我们来分步骤介绍如何配置. PS:本篇文章在ubuntu server 14.04和ce

CentOS 6使用mutt+msmtp发送邮件

转:http://www.tuicool.com/articles/YRnQVfq CentOS系统下如果希望向外域发送邮件,需要配置sendmail+dovecot等一系列工具.其实不用这么麻烦,只要mutt+msmtp就可以实现向外域发送邮件的功能了.本文基于CentOS6 64bit. 1,安装配置msmtp $ yum install gcc gcc-c++ gnutls gnutls-devel gnutls-utils openssl openssl-devel libidn lib

centos 6.6 系统中配置sendmail和dovecot

网上介绍sendmail的文章千百种,很少有跟着做下来一次成功的.多少都有些说的不准确的地方. 我给大家共享一下我经过实验环境测试,完全可行的方法. 1.软件准备 操作系统:centos6.6我选择centos6.6,以下软件,centos6.6全部自带,无需另外下载.邮件系统: cyrus-sasl-gssapi-2.1.23-15.el6_6.2.x86_64cyrus-sasl-2.1.23-15.el6_6.2.x86_64sendmail-cf-8.14.4-9.el6_8.1.noa