Postfix软件使用分析

Postfix简介:

在IBM的GPL协议下开发的MTA(邮件传输代理)软件,Postfix更快更容易管理,更安全,同时与sendmail保持兼容。
官网地址:http://www.postfix.org/

邮件服务器发信原理图:

未分类

postfix构建组成图:

未分类

要点:

Postfix mail queue(Postfix队列):
1 maildrop queue
maildrop queue 是通过Postfix sendmail 命令发送但是还未被Postfix pickup 服务加到postfix 主队列的邮件所处的队列
2 hold queue
smtpd access 策略或者是cleanup的检查可以将部分邮件长时间的放置在hold queue队列
3 incoming queue
所有进入postfix队列的邮件都会由cleanup放置到incoming queue里。
4 active queue
准备发送的邮件队列
瓶颈:CPU、I/O
5 deferred queue
一些发送失败的邮件队列

Postfix收件流程图:

未分类

Postfix基本配置:

Postfix的配置项大概有100个,所以这还真是个问题
1、myorigin 参数指明发件人所处的域
2、mydestination 参数指明Postfix接收邮件中收件人所处的域
3、myhostname 参数指明Postfix运行的主机名
4、mynetworks 参数指定Postfix所在的网络地址
5、inet_interfaces 参数指定postfix系统监听的端口

Postfix内容检查模块:

1、内置检查
2、前置队列检查
3、后置队列检查(简单设置、高级设置):
简单Filter:效率低,鲁棒性低,命令行调用
高级Filter:效率高,鲁棒,SMTP协议调用

Postfix性能调优

在postfix已经能够正常工作之后进行的性能优化工作。

  1. 邮件接收
    可以使用性能调优工具ashape,来查看maildrop queue,incoming queue,和activequeue的状态,根据情况调节DNS查找性能:可以运行一个本地DNS server 用来提高DNS查找所需要的时间消除不必要的LDAP查询当Postfix对客户端的响应过慢时:通过debug的方式查找日志排查问题,postfix收发邮件失败或成功都会记录日志关闭header_checks和body——checks模式关闭chroot_operation如果日志中记录client unkown则可能是因为DNS出错smtpd的进程数达到了master.cf中的限制
    更多关于smtpd server processes的性能问题:
    postfix2.0或更新的版本在想smtp client 报告一个错误的时候会暂停,这会造成延迟,可以通过关闭错误邮件回复的延时设定来规避这个问题。通过以上设定,postfix或者更新的版本在同样数目的SMTP server 进程数的基础上能够更多的处理SMTP客户端的链接。其他…

  2. 邮件分发
    可以使用性能调优工具ashape,来查看maildrop queue,incoming queue,和activequeue的状态,根据情况调节通过qshape检查每个消息提交多个收件人。而不是分条多个提交使用SMTP协议提交邮件,而不是使用“sendmail”命令,调整smtpd_recipient_limit设置通过优化提交mail的并行参数或者打开postfix 的in_flow_delay设置,使得邮件的提交速度不要超过硬盘的I/O新建一个本地的DNS server减少smtp_connect_timeout and smtp_helo_timeout 的值,以减少发送邮件到没有回复SMTP server 所消耗的时间为有问题的邮件设置专用的邮件传输策略对第一次投递失败的右键使用fallback_relay加大缓存使用固态硬盘调整递延邮件传递尝试的频率调整同时投递的数量调整每次投递的收件人数量

  3. 其他
    调整Postfix 的进程数调整系统上的进程数调整打开的文件数和sockets数(节约资源)

Postfix瓶颈分析

Postfix系统内置了性能分析工具qshape,通过qshape能够定位导致Postfix性能问题的位置。
该分析的关注点在Postfix queue队列拥塞问题上,可以查看各个队列的统计信息

qshape的使用:

运行在root账号下的qshape能够提供一个Postfix 队列信息的表格视图,在横轴上它为当前消息提供了细粒度队列年龄,为旧消息提供了粗粒度的队列年龄薪资,纵轴提供了消息的目的地址,对于域名消息数最多的最先显示。

比如我们可以查看一下前十名的垃圾邮件信息:
命令qshape -s hold | head

未分类

用qshape做问题定位:
qshape incomingqshape activeqshape deferred | headetc..

Postfix SASL认证

配置SASL需要两部,一是配置SASL认证列表和认证所需的后端,比如密码文件或其他数据源,二是配置postfix使其启用SASL。

目前Postfix 支持Cyrus SASL和Dovecot SASL两种认证的实现方式。

以Dovecot为例(Dovecot配置):

未分类

Postfix启用SASL:
如果Dovecot使用Unix 套接字
/etc/postfix/main.cf:
smtpd_sasl_type = dovecot

如果Dovecot使用TCP套接字(将127.0.0.1改成远端IP可进行远程认证)
/etc/postfix/main.cf:
smtpd_sasl_path = inet:127.0.0.1:12345

启用SASL认证:
/etc/postfix/main.cf:
smtpd_sasl_auth_enable = yes
配置好之后重启或reload Postfix即可

验证:

未分类

其他SMTP server SASL可选的配置参数:
单点登录默认验证域可指定网段免认证在邮件头添加SALS认证用户名客户端SASL认证配置:略..

Postfic TLS 支持
(TLS能够提供基于证书的加密和认证会话)

开启Postfix 的TLS支持,不仅意味着获得了加密邮件加密远程SMTP客户端认证信息的能力,还意味着打开了成千上万行代码(意味着会有性能损失或者产生BUG)

Postfix TSL工作流程:

未分类

smtpd8实现了基于TLS的SMTP服务端smtp8实现了基于TLS的SMTP 客户端tlsmgr8负责生成伪随机数,保持会话
配置TLS:

生成证书文件指定证书文件/etc/postfix/main.cf:
smtpd_tls_cert_file = /etc/postfix/server.pem

smtpd_tls_key_file = $smtpd_tls_cert_file启用TLS/etc/postfix/main.cf:
smtpd_tls_security_level = may

其他:
telnet 25 端口加密发件

如何在redhat上安装并配置Postfix

Postfix是一套邮件传输代理(简称MTA),用于发送并接收邮件。在本教程中,我们将安装并配置Postfix,并利用它仅为本地应用发送邮件——所谓本地应用,即与Postfix安装于同一服务器的应用。

一、搭建DNS服务

1.安装bind包

未分类

2.更改主配置文件 vim /etc/named.conf:

未分类

3.更改区域配置文件 vim /etc/named.rfc1912.zones

未分类

4.更改区域数据配置文件

(1) cp -p named.localhost benet.com.zone 将模板配置文件拷贝到新建的区域配置文件中,区域数据配置文件存放在 /var/named/下

未分类

(2) 编辑区域数据配置文件

未分类

未分类

5.重启服务,并测试

未分类

二、postfix配置

linux默认安装好postfix服务包,所以无需安装。

1.编辑postfix配置文件,配置文件是/etc/postfix/main.cf,进行如下的操作。

未分类

未分类

未分类

未分类

2.开启服务

未分类

三、Dovecot配置

1.安装dovecot安装包

未分类

2.编辑/etc/dovecot下的dovecot配置文件dovecot.conf

未分类

3.编辑/etc/dovecot/conf.d/10-mail.conf 开启邮箱的位置及格式

未分类

4.开启dovecot服务

未分类

四、在linux和windows7环境下测试

1.在linux客户端测试

(1).创建邮箱用户组,并创建用户,将用户添加到邮箱组,设置密码

未分类

(2).登陆zhangsan用户,发送给邮件给lisi用户

未分类

(3).用lisi用户登陆到接收邮件服务,并查看邮箱内容

未分类

2.在windows 7 下安装postfix进行测试

(1)关闭linux服务器的防火墙并更改win7 ip地址

未分类

未分类

(2)在fixmail下登陆zhangsan用户,

未分类

发送邮件给lisi

未分类

3)登陆lisi邮箱

未分类

可以看到zhangsan给lisi发的邮件内容。

未分类

CentOS7下搭建postfix邮箱服务器并实现extmail的web访问

闲来无事想着尝试使用postfix搭建一个邮箱服务器,我是边搭建边写这个笔记,搭建过程中遇到坑也会一并记录,使用的系统版本如下:

[root@localhost ~]# cat /etc/redhat-release
CentOS Linux release 7.2.1511 (Core)

本示例基于LNMP环境。

1. 准备工作

关闭selinux

[root@localhost ~]# setenforce 0
[root@localhost ~]# getenforce 
Permissive
[root@localhost ~]#

关闭firewalld防火墙,并清空iptables规则:

[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# iptables -F
[root@localhost ~]# iptables -X
[root@localhost ~]# iptables -nvL
Chain INPUT (policy ACCEPT 38 packets, 7291 bytes)
 pkts bytes target     prot opt in     out     source               destination         

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination         

Chain OUTPUT (policy ACCEPT 12 packets, 1208 bytes)
 pkts bytes target     prot opt in     out     source               destination         
[root@localhost ~]#

由于CentOS7默认安装的是MariaDB,所以要添加MySQL的yum源,有些编译需要的devel包只有epel扩展源有,所以我们需要把epel源也一并添加。因为是通过wget命令从下载地址中下载,但是最小化安装的CentOS7不自带wget命令,还需要先安装这个命令:

yum install -y wget
wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
rpm -ivh mysql-community-release-el7-5.noarch.rpm
wget http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -ivh epel-release-latest-7.noarch.rpm

2. 安装postfix

首先需要安装编译环境及其他所需要的包,免得一会编译过程中老报缺少包的错误,因为需要安装的包有点多,所以这个过程有点慢:

yum install nginx vim gcc gcc-c++ openssl openssl-devel db4-devel ntpdate mysql mysql-devel mysql-server bzip2 php-mysql cyrus-sasl-md5 perl-GD perl-DBD-MySQL perl-GD perl-CPAN perl-CGI perl-CGI-Session cyrus-sasl-lib cyrus-sasl-plain cyrus-sasl cyrus-sasl-devel libtool-ltdl-devel telnet mail libicu-devel  -y

安装完以上所需的包后,开始编译安装postfix:

1)首先卸载系统自带的postfix,并删除postfix用户,重新指定uid、gid创建新用户postfix,postdrop,嫌一条条命令去执行有点麻烦就写成脚本文件去执行:

yum remove postfix -y
userdel postfix
groupdel postdrop
groupadd -g 2525 postfix
useradd -g postfix -u 2525 -s /sbin/nologin -M postfix
groupadd -g 2526 postdrop
useradd -g postdrop -u 2526 -s /sbin/nologin -M postdrop

2)下载源码包并解压编译(如果下载地址失效就到官网去找下载连接):

cd /usr/local/src/
wget http://cdn.postfix.johnriley.me/mirrors/postfix-release/official/postfix-3.0.11.tar.gz
tar -zxvf postfix-3.0.11.tar.gz
cd postfix-3.0.11
make makefiles 'CCARGS=-DHAS_MYSQL -I/usr/include/mysql -DUSE_SASL_AUTH -DUSE_CYRUS_SASL -I/usr/include/sasl -DUSE_TLS ' 'AUXLIBS=-L/usr/lib64/mysql -lmysqlclient -lz -lrt -lm -L/usr/lib64/sasl2 -lsasl2   -lssl -lcrypto'
make && make install
echo $?

在make install环节的时候会有个交互式的界面,可以自定义一些目录,我这里只更改了第二项临时文件目录,其他的都选择了默认目录:

Please specify the prefix for installed file names. Specify this ONLY
if you are building ready-to-install packages for distribution to OTHER
machines. See PACKAGE_README for instructions.
install_root: [/] 

Please specify a directory for scratch files while installing Postfix. You
must have write permission in this directory.
tempdir: [/usr/local/src/postfix-3.0.11] /tmp/extmail     // 就只更改这一项为tmp目录,其他的全部默认

Please specify the final destination directory for installed Postfix
configuration files.
config_directory: [/etc/postfix] 

Please specify the final destination directory for installed Postfix
administrative commands. This directory should be in the command search
path of adminstrative users.
command_directory: [/usr/sbin] 

Please specify the final destination directory for installed Postfix
daemon programs. This directory should not be in the command search path
of any users.
daemon_directory: [/usr/libexec/postfix] 

Please specify the final destination directory for Postfix-writable
data files such as caches or random numbers. This directory should not
be shared with non-Postfix software.
data_directory: [/var/lib/postfix] 

Please specify the final destination directory for the Postfix HTML
files. Specify "no" if you do not want to install these files.
html_directory: [no] 

Please specify the owner of the Postfix queue. Specify an account with
numerical user ID and group ID values that are not used by any other
accounts on the system.
mail_owner: [postfix] 

Please specify the final destination pathname for the installed Postfix
mailq command. This is the Sendmail-compatible mail queue listing command.
mailq_path: [/usr/bin/mailq] 

Please specify the final destination directory for the Postfix on-line
manual pages. You can no longer specify "no" here.
manpage_directory: [/usr/local/man] 

Please specify the final destination pathname for the installed Postfix
newaliases command. This is the Sendmail-compatible command to build
alias databases for the Postfix local delivery agent.
newaliases_path: [/usr/bin/newaliases] 

Please specify the final destination directory for Postfix queues.
queue_directory: [/var/spool/postfix] 

Please specify the final destination directory for the Postfix README
files. Specify "no" if you do not want to install these files.
readme_directory: [no]

Please specify the final destination pathname for the installed Postfix
sendmail command. This is the Sendmail-compatible mail posting interface.
sendmail_path: [/usr/sbin/sendmail] 

Please specify the group for mail submission and for queue management
commands. Specify a group name with a numerical group ID that is
not shared with other accounts, not even with the Postfix mail_owner
account. You can no longer specify "no" here.
setgid_group: [postdrop] 

Please specify the final destination directory for Postfix shared-library
files.
shlib_directory: [no]

3)更改目录的属主和属组:

chown -R postfix:postdrop /var/spool/postfix
chown -R postfix:postdrop /var/lib/postfix/
chown root /var/spool/postfix
chown -R root /var/spool/postfix/pid

4)修改postfix的配置文件:

[root@localhost ~]# vim /etc/postfix/main.cf
myhostname = mail.everyoo.com        //设置主机名
mydomain = everyoo.com        //指定域名
myorigin = $mydomain        //指明发件人所在的域名
inet_interfaces =         //all指定postfix系统监听的网络接口
mydestination = $myhostname, localhost.$mydomain, localhost,$mydomain        //指定postfix接收邮件时收件人的域名 [使用虚拟域需要禁用]
mynetworks_style = host        //指定信任网段类型
mynetworks = 192.168.77.1/24, 127.0.0.0/8        //指定信任的客户端
relay_domains = $mydestination        //指定允许中转邮件的域名
alias_maps = hash:/etc/aliases        //设置邮件的别名

5)然后需要在/etc/init.d/目录下提供一个脚本来管理postfix的启动与停止:

[root@localhost /var/www/extsuite/extman]# vim /etc/init.d/postfix

把下面的内容放在/etc/init.d/postfix里面:

#!/bin/bash
#
# postfix      Postfix Mail Transfer Agent
#
# chkconfig: 2345 80 30
# description: Postfix is a Mail Transport Agent, which is the program 
#              that moves mail from one machine to another.
# processname: master
# pidfile: /var/spool/postfix/pid/master.pid
# config: /etc/postfix/main.cf
# config: /etc/postfix/master.cf

# Source function library.
. /etc/rc.d/init.d/functions

# Source networking configuration.
. /etc/sysconfig/network

# Check that networking is up.
[ $NETWORKING = "no" ] && exit 3

[ -x /usr/sbin/postfix ] || exit 4
[ -d /etc/postfix ] || exit 5
[ -d /var/spool/postfix ] || exit 6

RETVAL=0
prog="postfix"

start() {
     # Start daemons.
     echo -n $"Starting postfix: "
        /usr/bin/newaliases >/dev/null 2>&1
     /usr/sbin/postfix start 2>/dev/null 1>&2 && success || failure $"$prog start"
     RETVAL=$?
     [ $RETVAL -eq 0 ] && touch /var/lock/subsys/postfix
        echo
     return $RETVAL
}

stop() {
  # Stop daemons.
     echo -n $"Shutting down postfix: "
     /usr/sbin/postfix stop 2>/dev/null 1>&2 && success || failure $"$prog stop"
     RETVAL=$?
     [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/postfix
     echo
     return $RETVAL
}

reload() {
     echo -n $"Reloading postfix: "
     /usr/sbin/postfix reload 2>/dev/null 1>&2 && success || failure $"$prog reload"
     RETVAL=$?
     echo
     return $RETVAL
}

abort() {
     /usr/sbin/postfix abort 2>/dev/null 1>&2 && success || failure $"$prog abort"
     return $?
}

flush() {
     /usr/sbin/postfix flush 2>/dev/null 1>&2 && success || failure $"$prog flush"
     return $?
}

check() {
     /usr/sbin/postfix check 2>/dev/null 1>&2 && success || failure $"$prog check"
     return $?
}

restart() {
     stop
     start
}

# See how we were called.
case "$1" in
  start)
     start
     ;;
  stop)
     stop
     ;;
  restart)
     stop
     start
     ;;
  reload)
     reload
     ;;
  abort)
     abort
     ;;
  flush)
     flush
     ;;
  check)
     check
     ;;
  status)
       status master
     ;;
  condrestart)
     [ -f /var/lock/subsys/postfix ] && restart || :
     ;;
  *)
     echo $"Usage: $0 {start|stop|restart|reload|abort|flush|check|status|condrestart}"
     exit 1
esac

exit $?

为脚本添加执行权限,并将服务添加到开机启动项中:

[root@localhost /var/www/extsuite/extman]# chmod +x /etc/init.d/postfix
[root@localhost /var/www/extsuite/extman]# chkconfig --add postfix
[root@localhost /var/www/extsuite/extman]# chkconfig postfix on
[root@localhost /var/www/extsuite/extman]# chown postfix.postfix -R /var/lib/postfix/
[root@localhost /var/www/extsuite/extman]# chown postfix.postfix /var/spool/ -R

3. 安装dovecot

yum安装:

[root@localhost ~]# yum install -y dovecot dovecot-mysql

配置dovecot:

[root@localhost ~]# cd /etc/dovecot/
[root@localhost dovecot]# vim dovecot.conf     //直接在配置文件最后添加即可
protocols = imap pop3
!include conf.d/*.conf
listen = *
base_dir = /var/run/dovecot/
[root@localhost dovecot]# cd conf.d/
[root@localhost conf.d]# vim 10-auth.conf
disable_plaintext_auth = no
[root@localhost conf.d]# vim 10-mail.conf
mail_location = maildir:~/Maildir
mail_location = maildir:/var/mailbox/%d/%n/Maildir
mail_privileged_group = mail
[root@localhost conf.d]# vim 10-ssl.conf
ssl = no
[root@localhost conf.d]# vim 10-logging.conf 
log_path = /var/log/dovecot.log
info_log_path = /var/log/dovecot.info
log_timestamp = "%Y-%m-%d %H:%M:%S "
[root@localhost conf.d]# cp auth-sql.conf.ext auth-sql.conf
[root@localhost conf.d]# vim auth-sql.conf
passdb {  
    driver = sql        

    # Path for SQL configuration file, see example-config/dovecot-sql.conf.ext  
    args = /etc/dovecot/dovecot-sql.conf.ext
}

userdb {  
    driver = sql  
    args = /etc/dovecot/dovecot-sql.conf.ext
}

编辑dovecot通过mysql认证的配置文件:

[root@localhost conf.d]# vim /etc/dovecot-mysql.conf
driver = mysql
connect = host=localhost dbname=extmail user=extmail password=extmail
default_pass_scheme = CRYPT
password_query = SELECT username AS user,password AS password FROM mailbox WHERE username = '%u'
user_query = SELECT maildir, uidnumber AS uid, gidnumber AS gid FROM mailbox WHERE username = '%u'

4. 安装courier-authlib

下载解压并编译:

[root@localhost ~]# cd /usr/local/src/
[root@localhost /usr/local/src]#  wget https://sourceforge.net/projects/courier/files/authlib/0.66.2/courier-authlib-0.66.2.tar.bz2
[root@localhost /usr/local/src]# tar -jxvf courier-authlib-0.66.2.tar.bz2
[root@localhost /usr/local/src]# cd courier-authlib-0.66.2
[root@localhost /usr/local/src/courier-authlib-0.66.2]# ./configure --prefix=/usr/local/courier-authlib     --sysconfdir=/etc     --without-authpam     --without-authshadow     --without-authvchkpw     --without-authpgsql     --with-authmysql     --with-mysql-libs=/usr/lib64/mysql     --with-mysql-includes=/usr/include/mysql     --with-redhat     --with-authmysqlrc=/etc/authmysqlrc     --with-authdaemonrc=/etc/authdaemonrc     --with-mailuser=postfix
[root@localhost /usr/local/src/courier-authlib-0.66.2]# make && makeinstall

编译过程中发生了一个错误:

configure: error: The Courier Unicode Library 1.2 appears not to be installed. You may need to install a separate development subpackage, in addition to the main package

这是因为Courier Unicode Library没有安装,我们下载courier-unicode-1.2并编译安装:

[root@localhost ~]# wget https://sourceforge.net/projects/courier/files/courier-unicode/1.2/courier-unicode-1.2.tar.bz2
[root@localhost ~]# tar jxvf courier-unicode-1.2.tar.bz2 
[root@localhost ~]# cd courier-unicode-1.2
[root@localhost courier-unicode-1.2]# ./configure
[root@localhost courier-unicode-1.2]# make && make install

完成Courier Unicode Library的安装后,倒回去再次编译courier-authlib就没问题了

配置courier-authlib:

[root@localhost  courier-authlib-0.66.2]# chmod 755 /usr/local/courier-authlib/var/spool/authdaemon
[root@localhost  courier-authlib-0.66.2]# cp /etc/authdaemonrc.dist  /etc/authdaemonrc
[root@localhost  courier-authlib-0.66.2]# cp /etc/authmysqlrc.dist  /etc/authmysqlrc
[root@localhost  courier-authlib-0.66.2]# vim /etc/authdaemonrc      //配置文件里的验证方法比较多,我们这里只使用authmysql
authmodulelist="authmysql"
authmodulelistorig="authmysql"
[root@localhost  courier-authlib-0.66.2]# vim /etc/authmysqlrc     //直接添加到配置文件尾部,然后去上面将响应系统默认的注视掉,或者删除即可
MYSQL_SERVER            localhost
MYSQL_USERNAME          extmail
MYSQL_PASSWORD          extmail
MYSQL_SOCKET            /var/lib/mysql/mysql.sock
MYSQL_PORT               3306
MYSQL_DATABASE          extmail
MYSQL_USER_TABLE        mailbox
MYSQL_CRYPT_PWFIELD     password
DEFAULT_DOMAIN          test.com
MYSQL_UID_FIELD         '2525'
MYSQL_GID_FIELD         '2525'
MYSQL_LOGIN_FIELD       username
MYSQL_HOME_FIELD        concat('/var/mailbox/',homedir)
MYSQL_NAME_FIELD        name
MYSQL_MAILDIR_FIELD     concat('/var/mailbox/',maildir)

courier-authlib添加服务启动脚本及其他:

[root@localhost  courier-authlib-0.66.2]# cp courier-authlib.sysvinit /etc/init.d/courier-authlib
[root@localhost  courier-authlib-0.66.2]# chmod +x /etc/init.d/courier-authlib
[root@localhost  courier-authlib-0.66.2]# chkconfig --add courier-authlib
[root@localhost  courier-authlib-0.66.2]# chkconfig courier-authlib on
[root@localhost  courier-authlib-0.66.2]# echo "/usr/local/courier-authlib/lib/courier-authlib" >> /etc/ld.so.conf.d/courier-authlib.conf
[root@localhost  courier-authlib-0.66.1]# ldconfig
[root@localhost  courier-authlib-0.66.1]# service courier-authlib start
Starting Courier authentication services: authdaemond

smtp以及虚拟用户相关的设置:

[root@localhost ~]# vim /usr/lib64/sasl2/smtpd.conf    //文件不存在,要自己创建
pwcheck_method: authdaemond
log_level: 3
mech_list: PLAIN LOGIN
authdaemond_path:/usr/local/courier-authlib/var/spool/authdaemon/socket
[root@localhost ~]# vim /etc/postfix/main.cf
##postfix支持SMTP##
smtpd_sasl_auth_enable = yes
smtpd_sasl_local_domain = ''
smtpd_recipient_restrictions = permit_mynetworks,permit_sasl_authenticated,reject_unauth_destination
broken_sasl_auth_clients=yes
smtpd_client_restrictions = permit_sasl_authenticated
smtpd_sasl_security_options = noanonymous
##postfix支持虚拟用户##
virtual_mailbox_base = /var/mailbox
virtual_mailbox_maps = mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf   //这里的配置文件需在后面extman
里复制过来
virtual_mailbox_domains = mysql:/etc/postfix/mysql_virtual_domains_maps.cf
virtual_alias_domains =
virtual_alias_maps = mysql:/etc/postfix/mysql_virtual_alias_maps.cf
virtual_uid_maps = static:2525
virtual_gid_maps = static:2525
virtual_transport = virtual

5. 安装extmail

下载extmail和extman:

[root@localhost ~]# cd /usr/local/src/
[root@localhost /usr/local/src]# wget http://7xivyw.com1.z0.glb.clouddn.com/extmail-1.2.tar.gz
[root@localhost /usr/local/src]# wget http://7xivyw.com1.z0.glb.clouddn.com/extman-1.1.tar.gz

创建站点目录并解压、重命名extmail包:

[root@localhost /usr/local/src]# mkdir -p /var/www/extsuite
[root@localhost /usr/local/src]# tar -zxvf extmail-1.2.tar.gz -C /var/www/extsuite/
[root@localhost /usr/local/src]# mv /var/www/extsuite/extmail-1.2/ /var/www/extsuite/extmail

更改extmail的配置文件:

[root@localhost ~]# cd /var/www/extsuite/extmail
[root@localhost extmail]# cp webmail.cf.default webmail.cf
[root@localhost extmail]# vim webmail.cf
SYS_SESS_DIR = /tmp/extmail
SYS_UPLOAD_TMPDIR = /tmp/extmail/upload
SYS_USER_LANG = zh_CN
SYS_MIN_PASS_LEN = 8
SYS_MAILDIR_BASE = /var/mailbox
SYS_MYSQL_USER = extmail
SYS_MYSQL_PASS = extmail
SYS_MYSQL_DB = extmail
SYS_MYSQL_HOST = localhost
SYS_MYSQL_SOCKET = /var/lib/mysql/mysql.sock
SYS_MYSQL_TABLE = mailbox
SYS_MYSQL_ATTR_USERNAME = username
SYS_MYSQL_ATTR_DOMAIN = domain
SYS_MYSQL_ATTR_PASSWD = password
SYS_AUTHLIB_SOCKET = /usr/local/courier-authlib/var/spool/authdaemon/socket

建立临时文件目录与session目录,并更改权限:

[root@localhost extmail]# mkdir -p /tmp/extmail/upload
[root@localhost extmail]# chown -R postfix.postfix /tmp/extmail/

6. 安装extman

回到extman的下载目录下,解压extman包:

[root@localhost ~]# cd /usr/local/src/
[root@localhost /usr/local/src]# tar -zxvf extman-1.1.tar.gz -C /var/www/extsuite/
[root@localhost /usr/local/src]# cd /var/www/extsuite/
[root@localhost /var/www/extsuite]# mv extman-1.1/ extman

拷贝extman的配置文件:

[root@localhost /var/www/extsuite]# cd extman/
[root@localhost /var/www/extsuite/extman]# cp webman.cf.default webman.cf

更改cgi目录的属主属组:

[root@localhost /var/www/extsuite/extman]# chown -R postfix.postfix /var/www/extsuite/extman/cgi/
[root@localhost /var/www/extsuite/extman]# chown -R postfix.postfix /var/www/extsuite/extmail/cgi/

导入数据库:

由于数据库不能识别TYPE=MyISAM,所以这里直接导入会出错,需要先编辑extmail.sql数据库文件,将文件中的TYPE=MyISAM更改为ENGINE=MyISAM,共有五处修改:

[root@localhost /var/www/extsuite/extman]# vim docs/extmail.sql
:% s/TYPE/ENGINE/g

我这里导入数据的时候发生了一个错误,提示找不到mysql.sock文件:

[root@localhost /var/www/extsuite/extman]# mysql -uroot < docs/extmail.sql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
[root@localhost /var/www/extsuite/extman]# ls /var/lib/mysql/mysql.sock
ls: 无法访问/var/lib/mysql/mysql.sock: 没有那个文件或目录

解决:然后我去查看了一下/etc/my.cnf文件,发现没问题,socket参数指向的也是 /var/lib/mysql/mysql.sock 这个路径,于是我就重启了mysql服务,然后再尝试就没有报找不到mysql.sock文件的错误了,但是报了另一个错误:

[root@localhost /var/www/extsuite/extman]# mysql -uroot < docs/extmail.sql
ERROR 1364 (HY000) at line 31: Field 'ssl_cipher' doesn't have a default value
[root@localhost /var/www/extsuite/extman]# 

这错误的意思是:字段 ‘ssl密码’ 没有默认值

于是又得去查看一下/etc/my.cnf文件,然后把sql_mode参数给注释掉:

未分类

接着重启mysql服务后,继续导入数据,这次就没问题了:

[root@localhost /var/www/extsuite/extman]# !service
service mysqld restart
Redirecting to /bin/systemctl restart  mysqld.service
[root@localhost /var/www/extsuite/extman]# mysql -uroot < docs/extmail.sql
[root@localhost /var/www/extsuite/extman]# mysql -uroot < docs/init.sql

导入数据成功后再次修改/etc/my.cnf文件,把刚刚注释的那行给去掉注释,不去掉的话,mysql服务可能会出现不能启动的问题:

未分类

数据导入成功后,登录mysql,创建一个mysql数据库用户extmail并授予权限:

[root@localhost /var/www/extsuite/extman]# mysql -uroot
mysql> GRANT ALL ON extmail.* to extmail@'%' identified by 'extmail';      //我这里是直接授予全部权限在任意的IP地址上了,实际情况根据需求而定
Query OK, 0 rows affected (0.00 sec)

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

mysql>

复制之前提到的配置文件:

[root@localhost ~]# cd /var/www/extsuite/extman/docs/
[root@localhost /var/www/extsuite/extman/docs]# cp mysql_virtual_* /etc/postfix/

为extman创建临时目录:

[root@localhost /var/www/extsuite/extman/docs]# mkdir /tmp/extman
[root@localhost /var/www/extsuite/extman/docs]# chown -R postfix.postfix /tmp/extman/

启动postfix、dovecot、saslauthd服务,并查看进程是否正常:

[root@localhost /var/www/extsuite/extman]# service postfix start
Starting postfix (via systemctl):                          [  确定  ]
[root@localhost /var/www/extsuite/extman]# ps aux |grep postfix
root      63586  0.0  0.1  95392  2160 ?        Ss   01:29   0:00 /usr/libexec/postfix/master -w
postfix   63587  0.0  0.2  95448  3808 ?        S    01:29   0:00 pickup -l -t unix -u
postfix   63588  0.0  0.2  95496  3816 ?        S    01:29   0:00 qmgr -l -t unix -u
root      63592  0.0  0.0 112680   976 pts/0    S+   01:33   0:00 grep --color=auto postfix
[root@localhost /var/www/extsuite/extman]#  ss -tnluo | grep :25
tcp    LISTEN     0      100       *:25                    *:*             
[root@localhost /var/www/extsuite/extman]# service dovecot start
Redirecting to /bin/systemctl start  dovecot.service
[root@localhost /var/www/extsuite/extman]# ps aux |grep dovecot
root      63834  0.3  0.0  15652  1484 ?        Ss   02:15   0:00 /usr/sbin/dovecot -F
dovecot   63837  0.0  0.0   9320  1012 ?        S    02:15   0:00 dovecot/anvil
root      63838  0.0  0.0   9448  1164 ?        S    02:15   0:00 dovecot/log
root      63840  0.0  0.1  12464  2196 ?        S    02:15   0:00 dovecot/config
root      63842  0.0  0.0 112680   972 pts/0    S+   02:15   0:00 grep --color=auto dovecot    
[root@localhost /var/www/extsuite/extman]# systemctl start saslauthd
[root@localhost /var/www/extsuite/extman]# ps aux |grep saslauthd
root      63131  0.0  0.0  69648   916 ?        Ss   01:19   0:00 /usr/sbin/saslauthd -m /run/saslauthd -a pam
root      63132  0.0  0.0  69648   676 ?        S    01:19   0:00 /usr/sbin/saslauthd -m /run/saslauthd -a pam
root      63133  0.0  0.0  69648   676 ?        S    01:19   0:00 /usr/sbin/saslauthd -m /run/saslauthd -a pam
root      63134  0.0  0.0  69648   676 ?        S    01:19   0:00 /usr/sbin/saslauthd -m /run/saslauthd -a pam
root      63135  0.0  0.0  69648   676 ?        S    01:19   0:00 /usr/sbin/saslauthd -m /run/saslauthd -a pam
root      63144  0.0  0.0 112680   972 pts/0    S+   01:20   0:00 grep --color=auto saslauthd
[root@localhost /var/www/extsuite/extman]# ps aux |grep courier-authlib
root      61661  0.0  0.0   4316   444 ?        S    00:07   0:00 /usr/local/courier-authlib/sbin/courierlogger -pid=/usr/local/courier-authlib/var/spool/authdaemon/pid -start /usr/local/courier-authlib/libexec/courier-authlib/authdaemond
root      61662  0.0  0.0  35512  1796 ?        S    00:07   0:00 /usr/local/courier-authlib/libexec/courier-authlib/authdaemond
root      61663  0.0  0.0  35512   468 ?        S    00:07   0:00 /usr/local/courier-authlib/libexec/courier-authlib/authdaemond
root      61664  0.0  0.0  35512   468 ?        S    00:07   0:00 /usr/local/courier-authlib/libexec/courier-authlib/authdaemond
root      61665  0.0  0.0  35512   468 ?        S    00:07   0:00 /usr/local/courier-authlib/libexec/courier-authlib/authdaemond
root      61666  0.0  0.0  35512   468 ?        S    00:07   0:00 /usr/local/courier-authlib/libexec/courier-authlib/authdaemond
root      61667  0.0  0.0  35512   468 ?        S    00:07   0:00 /usr/local/courier-authlib/libexec/courier-authlib/authdaemond
root      63660  0.0  0.0 112680   980 pts/0    S+   02:00   0:00 grep --color=auto courier-authlib

7. 测试

测试虚拟用户:

[root@localhost courier-authlib-0.66.2]# /usr/local/courier-authlib/sbin/authtest -s login postmaster@extmail.org extmail
Authentication succeeded.                //显示这个表示成功,测试时使用的是postmaster@extmail.org,因为我们导入的数据库init.sql里面自带了这个。
Authenticated: postmaster@extmail.org  (uid 2525, gid 2525)
Home Directory: /var/mailbox/extmail.org/postmaster  //这里需要注意/var/mailbox这个目录现在我们还没有创建,后面web访问的时候如果没有会报错,所以提前创建。
                    Maildir: /var/mailbox/extmail.org/postmaster/Maildir/
                    Quota: (none)
            Encrypted Password: $1$phz1mRrj$3ok6BjeaoJYWDBsEPZb5C0
                Cleartext Password: extmail
                    Options: (none)
[root@localhost courier-authlib-0.66.2]# mkdir /var/mailbox
[root@localhost courier-authlib-0.66.2]# chown -R postfix.postfix /var/mailbox/

测试smtp发信:

[root@localhost ~]# printf   "postmaster@extmail.org" | openssl base64
cG9zdG1hc3RlckBleHRtYWlsLm9yZw==
[root@localhost ~]#  printf   "extmail" | openssl base64
ZXh0bWFpbA==
[root@localhost ~]# telnet localhost 25
Trying ::1...
telnet: connect to address ::1: Connection refused
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
220 mail.daen.com ESMTP Postfix
auth login
334 VXNlcm5hbWU6
cG9zdG1hc3RlckBleHRtYWlsLm9yZw==
334 UGFzc3dvcmQ6
ZXh0bWFpbA==
235 2.7.0 Authentication successful     //成功
quit
221 2.0.0 Bye
Connection closed by foreign host.

8. 启动nginx实现web访问

nginx本身并不能解析cgi,extmail自带了解析cgi的程序,但是有些地方需要修改下:

[root@localhost ~]# vim /var/www/extsuite/extmail/dispatch-init
SU_UID=postfix
SU_GID=postfix

启动dispatch-init:

[root@localhost ~]# /var/www/extsuite/extmail/dispatch-init start
Starting extmail FCGI server...
[root@localhost ~]# /var/www/extsuite/extman/daemon/cmdserver -v -d 
loaded ok

添加nginx虚拟主机:

vim /etc/nginx/conf.d/extmail.conf

文件内容如下:

server {
   listen       8080;
   server_name  mail.everyoo.com;
   index index.html index.htm index.php index.cgi;
   root  /var/www/extsuite/extmail/html/;
   location /extmail/cgi/ {
             fastcgi_pass          127.0.0.1:8888;
             fastcgi_index         index.cgi;
             fastcgi_param  SCRIPT_FILENAME   /var/www/extsuite/extmail/cgi/$fastcgi_script_name;
             include               fcgi.conf;
        }
        location  /extmail/  {
             alias  /var/www/extsuite/extmail/html/;
        }
        location /extman/cgi/ {
             fastcgi_pass          127.0.0.1:8888;
             fastcgi_index         index.cgi;
             fastcgi_param  SCRIPT_FILENAME   /var/www/extsuite/extman/cgi/$fastcgi_script_name;
             include            fcgi.conf;
        }
        location /extman/ {
             alias  /var/www/extsuite/extman/html/;
        }
      access_log  /var/log/extmail_access.log;
}

创建fcgi.conf文件:

vim /etc/nginx/fcgi.conf

文件内容如下:

fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;
fastcgi_param  SERVER_SOFTWARE    nginx;
fastcgi_param  QUERY_STRING       $query_string;
fastcgi_param  REQUEST_METHOD     $request_method;
fastcgi_param  CONTENT_TYPE       $content_type;
fastcgi_param  CONTENT_LENGTH     $content_length;
fastcgi_param  SCRIPT_NAME        $fastcgi_script_name;
fastcgi_param  REQUEST_URI        $request_uri;
fastcgi_param  DOCUMENT_ROOT      $document_root;
fastcgi_param  SERVER_PROTOCOL    $server_protocol;
fastcgi_param  REMOTE_ADDR        $remote_addr;
fastcgi_param  REMOTE_PORT        $remote_port;
fastcgi_param  SERVER_ADDR        $server_addr;
fastcgi_param  SERVER_PORT        $server_port;
fastcgi_param  SERVER_NAME        $server_name;

安装Unix::Syslog:

[root@localhost ~]# cd /usr/local/src/
[root@localhost /usr/local/src]# wget http://www.cpan.org/authors/id/M/MH/MHARNISCH/Unix-Syslog-1.1.tar.gz
[root@localhost /usr/local/src]# tar zxvf Unix-Syslog-1.1.tar.gz 
[root@localhost /usr/local/src]# cd Unix-Syslog-1.1
[root@localhost /usr/local/src/Unix-Syslog-1.1]# perl Makefile.PL
[root@localhost /usr/local/src/Unix-Syslog-1.1]# make && make install

启动nginx,并检查进程和监听端口是否正常:

[root@localhost ~]# service nginx start
Redirecting to /bin/systemctl start  nginx.service
[root@localhost ~]# ps aux |grep nginx
root      72338  0.0  0.1 122892  2296 ?        Ss   03:22   0:00 nginx: master process /usr/sbin/nginx
nginx     72339  0.0  0.1 123336  3192 ?        S    03:22   0:00 nginx: worker process
nginx     72340  0.0  0.1 123336  3192 ?        S    03:22   0:00 nginx: worker process
nginx     72341  0.0  0.1 123336  3192 ?        S    03:22   0:00 nginx: worker process
nginx     72342  0.0  0.1 123336  3192 ?        S    03:22   0:00 nginx: worker process
root      72344  0.0  0.0 112680   976 pts/0    S+   03:22   0:00 grep --color=auto nginx
[root@localhost ~]# netstat -lntp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 0.0.0.0:110             0.0.0.0:*               LISTEN      63834/dovecot       
tcp        0      0 0.0.0.0:143             0.0.0.0:*               LISTEN      63834/dovecot       
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      72338/nginx: master 
tcp        0      0 0.0.0.0:8080            0.0.0.0:*               LISTEN      72338/nginx: master 
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1482/sshd           
tcp        0      0 127.0.0.1:8888          0.0.0.0:*               LISTEN      64100/dispatch.fcgi 
tcp        0      0 0.0.0.0:25              0.0.0.0:*               LISTEN      64328/master        
tcp6       0      0 :::3306                 :::*                    LISTEN      62442/mysqld        
tcp6       0      0 :::80                   :::*                    LISTEN      72338/nginx: master 
tcp6       0      0 :::22                   :::*                    LISTEN      1482/sshd           
[root@localhost ~]# 

然后到windows上访问你服务器IP的8080端口:

未分类

extman的登录账户为root@extmail.org密码为extmail123,首次使用需要先添加域,添加之后再修改域,改为可自由注册,再注册用户就可以登录发邮件了:

未分类

Linux系统,Centos7版本下搭建postfix服务器及其相关配置应用

实验报告

一、 实验名称:邮件服务器的搭建和相关使用功能的配置

二、 实验环境与要求:Linux系统 centos7版本

搭建邮件服务器实现发信收信基本功能
实现发信认证功能
搭建好LAMP环境,配置squirrelmail收发邮件

三、 实验内容:

1、 检查版信息,postfix安装情况与支持的功能,启动运行;
2、 搭建与之相关的DNS服务器,配置DNS解析功能;
3、 配置postfix基本发信功能,进行测试;
4、 安装dovecot提供收信服务,进行测试;
5、 客户端利用邮箱软件配置测试服务器功能;
6、 进行发信认证配置;
7、 搭建LAMP环境,配置squirrelmail收发邮件

实验步骤

第一步

cat /etc/redhat-release //检查版本信息

未分类

※安装postfix(版本自带) centos7版本即使用最小化安装仍自带此功能

postconf -a // 验证是否支持cyrus dovecot功能

未分类

启动服务器systemctl start postfix

netstat -anpt | grep 25 //查看监听端口号

未分类

第二步

※搭建与之相关的DNS服务器,配置DNS解析功能

yum install bind //安装服务器程序
vi /etc/named.conf //编辑主配置文件

未分类

未分类

※以下进行区域文件配置:

cd /var/named/ 进入文件目录下

复制配置文件的模板进行修改:

cp -p named.localhost yyf.com.zone
cp -p named.localhost yyf.com.local
vi /var/named/yyf.com.zone 编辑正向区文件

如图:

未分类

vi /var/named/yyf.com.local 编辑反向区文件

如图:

未分类

以上基本配置编辑完成

systemctl start named //启动服务器
netstat -anpu | grep name //检测到UDP 53端口在监听 服务器正常工作。

进行DNS验证

vi /etc/resolv.conf
nameserver 192.168.80.18 //指向DNS服务器地址

rpm -ivh /mnt/Packages/bind-utils-9.9.4-50.el7.x86_64.rpm //安装检测命令nslookup

解析如图:

~nslookup mail.yyf.com //正向解析 

未分类

~nslookup 192.168.80.18 //反向解析

未分类

解析成功!

第三步

—–配置postfix基本发信功能

vi /etc/postfix/main.cf 编辑配置文件 修改项如下:

myhostname = mail.aa.com //本机系统主机名
mydomain = aa.com //主机域名
myorigin = $mydomain //根源、起点
inet_interfaces = 192.168.80.18, 127.0.0.1 //接口地址
inet_protocols = ipv4
mydestination = $myhostname, $mydomain //预定、指定范围
home_mailbox = Maildir/ //信箱家目录

完成后保存退出,用postfix check命令检查是否存在语法错误:

service postfix restart //重启邮件服务器

※要测试发信功能是否生效,我们需要添加用户并加入同一组管理:
—–增加邮件测试账号

groupadd mailusers //增加组账号
useradd -g mailusers -s /sbin/nologin jack //建用户jack 加入mailusers组且不可登陆系统
passwd jack(密码随便设置123)
useradd -g mailusers -s /sbin/nologin tom //建用户tom 加入mailusers组且不可登陆系统
passwd tom(密码随便设置123)

测试准备:安装yum install telnet
开始测试:连接服务器的25端口进行简单发信测试
telnet mail.yyf.com 25

依次输入以下内容:

如图:

未分类

由于目前未安装收件服务,所以只能通过root超级管理员来查看邮件是否发送成功

使用root查看tom用户是否收到测试邮件:

ls -l /home/tom/Maildir/new/ 在此目录下应该会有刚才发的邮件

未分类

可用cat命令查看内容

邮件发送功能测试成功!

第四步

※安装dovecot提供收信服务

yum install dovecot //安装系统程序
vi /etc/dovecot/dovecot.conf //配置程序文件

※修改项如下:

protocols = imap pop3 lmtp
listen = //监听 所有端口
!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端口需要监听

如图:

未分类

服务启动成功,正常工作

※现在可以用户进行测试收信了(以前是用root,现在可以用账户)
测试开始:telnet mail.yyf.com 110

如图:

未分类

我们来读取第一份邮件看看

显示如图:

未分类

用quit 可以退出
测试结构说明收件系统工作正常

鉴于目前的收信发信方式太不友好,安装MUA软件连接服务器收发邮件

※客户端装测设软件:

未分类

用此软件进行测试,看服务器是否正常工作
基本设置如图所示:

未分类

未分类

登陆后收件:

未分类

邮件接受正常
服务器工作正常

第五步

以下进行发信认证配置

yum install cyrus-sasl* 安装相关软件包

vi /etc/sasl2/smtpd.conf 开始编辑配置文件,内容如下:

pwcheck_method: saslauthd
mech_list: plain login
log_level:3 //设置日志级别为3
vi /etc/sysconfig/saslauthd //编辑认证系统配置文件
MECH=shadow

service saslauthd start //开启认证功能服务器
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 restart //重启服务器

※测试普通发信

telnet mail.yyf.com 25

如图:

未分类

向未认证区域发件失败说明认证系统是生效的
quit 退出

※下面用系统账户进行发信测试

将用户名与密码生成密文加密:

printf "jack" | openssl base64 //生成密文
amFjaw== (密文)
printf "123" | openssl base64 //生成密文
MTIz (密文)

※开始用字符终端测试认证发信:

telnet mail.aa.com 25

如图:

未分类

未分类

若在真机用邮箱软件测试,只需做如下操作:

未分类

将高级设置中的选项勾选即可验证

第六步

—-以下是配置squirrelmail收发邮件内容
需要搭建好LAMP环境

--------安装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 //设置时区

提醒:系统中的防火墙与安全Linux要确认关闭,否则影响实验

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.18 将出现如下页面,说明设置成功

未分类

※进入数据库,建立授权账号

mysql -u root -p

进数据库时设置一下密码:123456

CREATE DATABASE bcd; //建立数据库名字bcd
GRANT all ON bcd.* TO 'mail'@'%' IDENTIFIED BY '123456'; 
flush privileges; //刷新一下权限

下面测试数据库工作是否正常

vi /var/www/html/index.php //编辑配置文件,该文件为数据库工作目录

删除以前内容,写入如下内容:

<?php
$link=mysql_connect('192.168.80.18','mail','123456'); //说明地址与密码
if($link) echo "<h1>Success!!</h1>"; //如果连接成功则会显示Success!!
else echo "Fail!!"; //如果连接失败则显示Fail!!
mysql_close();
?>

保存退出

测试:

未分类

连接成功!

到下面网址下载小松鼠包与汉化语言包

http://www.squirrelmail.org/download.php

1、squirrelmail-webmail-1.4.22.tar.gz
2、all_locales-1.4.18-20090526.tar.gz

将安装包上传到Linux系统中进行解压

tar xzvf squirrelmail-webmail-1.4.22.tar.gz
tar xzvf all_locales-1.4.18-20090526.tar.gz -C squirrelmail-webmail-1.4.22 //-C表示将语言包解压到后续包中

cp -rv squirrelmail-webmail-1.4.22 /var/www/html/mail //将解压完成的包拷贝到/var/www/html/mail(网页工作目录)

cd /var/www/html/mail // cd到php工作目录下
mkdir attach //建立附件文件目录
chown -R apache:apache attach/ data/ //修改权限

cd config //到squirrelmail配置文件下
cp config_default.php config.php // 拷贝模板
vi config.php //开始编辑

修改内容如下:

$domain = 'aa.com'; //域名
$imap_server_type = 'dovecot'; //imap服务类型为dovecot
$data_dir = '/var/www/html/mail/data'; //原件存放地址
$attachment_dir = '/var/www/html/mail/attach/'; //附件存放地址
$squirrelmail_default_language = 'zh_CN'; //网页显示语言为中文
$default_charset = 'zh_CN.UTF-8'; //中文字符编码

用真机浏览器登陆测试:

http://192.168.80.181/mail

出现登录界面,如图:

未分类

输入账户登陆:
显示如下:

未分类

成功进入并且可正常操作使用,服务器工作正常。

第七步

※以下设置邮件组

vi /etc/aliases 编辑配置文件

增加组名:student:jack,tom

newaliases //生成hash数据库文件
systemctl restart postfix //重启邮件服务器br/>测试向student@yyf.com发信的时候jack,tom都会收到。

测试如下:

※用tom向组邮箱发送组邮件

未分类

检查收件情况:

未分类

未分类

测试结果符合要求

※以下设置邮件大小

vi /etc/postfix/main.cf //编辑配置文件

手动写入:

message_size_limit = 5120000 //单位是Byte

保存后退出!

systemctl restart postfix //重启邮件服务器

通过增加大附件测试效果

未分类

未分类

※以下通过配置用户磁盘配额实现限制用户邮箱空间
邮件存放目录在home下,挂载于/dev/sda5盘上

未分类

[root@yyf ~]# umount /home
[root@yyf ~]# mount -o usrquota,grpquota /dev/sda5
[root@yyf ~]# vi /etc/fstab

最后一行加上:

未分类

未分类

开启磁盘配额:

edquota -u jack

配额硬性为20M 如图:

未分类

用户系统中检测磁盘配额是否生效:

未分类

超出配额,已生效。
用客户端软件测试:

发送大小为6.6M的邮件,已成功发送两个(已取消单个邮件不得大于5M的配置)

未分类

第三份发送失败

未分类

查看目录剩余空间,限额20M的情况下,已不足6.6M的空间,故第三份发送必然失败

未分类

所以对jack用户做的磁盘配额生效。

CentOS6安装postfix并设置sasl

postfix是一个流行的smtp服务器。在不采用ssl/tls加密的情况下,smtp服务器默认端口是25/TCP。下面介绍如何在CentOS6上安装postfix。

1. CentOS6默认已经安装了postfix.如果系统没有postfix的话,可以采用如下命令安装它。

[root@mail ~]# yum -y install postfix

2. 配置postfix的main.cf,配置smtp-auth采用dovecot的sasl功能。需要安装和配置dovecot,见下篇。

[root@mail ~]# vi /etc/postfix/main.cf
# 第75行: 去掉注释,并设置主机名。
myhostname = mail.opsky.top
# 第83行: 去掉注释,并设置域名。
mydomain = opsky.top
# 第99行: 去掉注释。
myorigin = $mydomain
# 第116行: 
inet_interfaces = all
# 第119行: 如果只使用ipv4,那么设置如下。
inet_protocols = ipv4
# 第164行: 配置可接收邮件的域名。
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
# 第264行: 去掉注释,并设置本地网络号段.
mynetworks = 127.0.0.0/8, 10.0.0.0/24
# 第419行: 去掉注释,采用Maildir格式。
home_mailbox = Maildir/
# 第571行: 
smtpd_banner = $myhostname ESMTP
# 添加如下配置到文件末尾
# 一封邮件大小限制为10M
message_size_limit = 10485760
# 一个邮箱大小限制为1G
mailbox_size_limit = 1073741824
# 配置SMTP-Auth采用dovecot的sasl功能
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noanonymous
smtpd_sasl_local_domain = $myhostname
smtpd_recipient_restrictions = permit_mynetworks,permit_auth_destination,permit_sasl_authenticated,reject

main.cf配置完毕后,启动postfix,并设置自动启动。

[root@mail ~]# /etc/rc.d/init.d/postfix start 
Starting postfix: [  OK  ]
[root@mail ~]# chkconfig postfix on

3. 如果iptables在开启状态,那么设置iptables开放smtp的25端口。

[root@mail ~]# iptables -I INPUT 5 -p tcp -m state --state NEW -m tcp --dport 25 -j ACCEPT

服务器搭建十一——Postfix 邮件服务器搭建

写在前面的话:
  已经三个多月,没有更新了,最近事情比较多。各种值班没有使用来写文章。也发生很多事情,想了很多事情吧。这篇文章也是很早之前就在做实验准备写了。先发一部分吧。

1. 测试环境

a)Centos 6.7 
b)测试软件postfix

2. 电子邮件原理

本文在将简要的记录,基于postfix、SASL、Dovecot搭建一个测试的邮件服务器。属于我学习的一个记录。现在搭建几乎每天都在使用电子邮件,你们对真正了解电子邮件原理的人不是特别多。电子邮件是怎么传输的呢?
  邮件系统:MUA (邮件用户代理) [其实就是客户端]、MTA(邮件传输代理)[服务器软件]、MDA(邮件投递代理)[从MTA接受邮件,放到本地的账户收件箱中]
  主要用到协议:SMTP (简单邮件传输协议)、POP(邮局协议)、IMAP(互联网邮件访问协议)
邮件传输过程:

未分类

  常用的邮件服务器软件:sendmail、postfix、Qmail
  在实际的系统中,MTA,MUA,MDA以及POP/IMAP服务器等组件均可以由不同软件承担,还包括账号管理,信箱管理,安全传输,以及web访问等。因此邮件系统的建立需要很多的软件集成。本文只是在使用postfix软件学习邮件服务器一些简单测试。
  简单邮件传输协议SMTP ——TCP/IP协议 传输层的协议 tcp 25
  邮局协议POP3 ——tcp 110 读取邮件时候使用的协议 客户端从服务器下载邮件
  Internet消息访问协议IMAP ——应用层协议 143端口 客户端和服务器 邮件读取协议(功能更多)

3. 软件安装

未分类

  通过上面可以查看系统默认已经安装postfix,并且已经在运行中,但是这个功能是不完善的,只有postfix服务提供了25端口,另一个与客户端连接的110端口还需其他软件。
  Postfix服务器的配置相当复杂,涉及到操作系统的用户认证、用户特权、数据库文件、DNS配置,还有web页面等等。本文只是对简单的配置入手,后续还需要学习。
  下面的是postfix源码安装时候下载地址。postfix
  Postfix 没有认知模块所以需要安装SASL配合认证

未分类

./configure --disable-anon --enable-login --enable-ntlm --with-saslauthd=/var/run/saslauthd

未分类

因为连接了外网,我是只有yum install gcc -y安装

未分类

  自己编译安装时候还是出现报错,查询写资料说是头文件造成的,需要修改些参数。但是具体操作我没有做,因为我发现系统是已经安装了cyrus-sasl 版本比我下载低了点。还有我使用系统是64位lib文件大部分都是在lib64中而不是lib中,这个需要特别注意

未分类

在安装问sasl和postfix可以检测下postfix是否使用了sasl2
  

ldd /usr/sbin/postconf

测试sasl和postfix是否配合

未分类

运行sasl

未分类

验证sasl

未分类

运行postfix
  
测试端口也正常

未分类

但是不能直接使用明文的用户名密码登录需要是 base64加密
  

root: cm9vdA==   1qaz1qaz: MXFhejFxYXo=

未分类

4. 配置环境

未分类

使用smtp的sasl验证时候需要在main.cf中加入

smtpd_recipient_restrictions =         permit_mynetworks,permit_sasl_authenticated,reject_unauth_destination,reject_non_fqdn_recipient
smtpd_sasl_application_name = smtpd

重启sasl和postfix。

再使用base64加密用户名和密码就,可以验证登录成功。

在main.cf主配置文件主要有以下内容需要注意:(后续在写客户端登录 web界面 等等在写吧 还有配置文件的,简单概述)

centos 7 vps 发送gmail邮件(通过postfix与mailx)

用于发送邮件的邮箱必须先开启低安全性登录。

未分类

postfix就是打算替代sendmail的,sendmail删了吧。

yum remove -y sendmail

安装postfix及支持

yum install -y postfix mailx cyrus-sasl-plain

把发邮件的邮箱的账号密码替换后执行。

echo "[smtp.gmail.com]:587 xxxxxxxx@gmail.com:xxxxxxxxx" > /etc/postfix/sasl_passwd

生成sasl_passwd.db

postmap hash:/etc/postfix/sasl_passwd

修改证书年限

cd /etc/ssl/certs/
vi Makefile
#把365改36500,有效期一百年,嘿嘿之后可以按需求改回来。

制作证书及ssl密钥,并移动

make server.pem
mv server.pem /etc/postfix/

修改postfix配置文件 /etc/postfix/main.cf ,清空替换成如下。

relayhost = [smtp.gmail.com]:587
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_tls_CAfile = /etc/postfix/server.pem
smtp_use_tls = yes

重启postfix

/bin/systemctl restart postfix.service

配置完成

可以通过下面命令查看postfix活动日志,排错就靠它了。

tail -f /var/log/maillog

发送测试邮件xxxx为收信地址

echo | mail -s 'is is a test l' xxxxxxxxx@gmail.com

如果成功那就是成功啦。

postfix 日常维护队列管理[邮件服务器维护]

example textpostfix有四种不同的邮件队列,并且由队列管理进程统一进行管理:

  • maildrop:本地邮件放置在maildrop中,同时也被拷贝到incoming中。

  • incoming:放置正在到达或队列管理进程尚未发现的邮件。

  • active:放置队列管理进程已经打开了并正准备投递的邮件,该队列有长度的限制。

  • deferred:放置不能被投递的邮件。

postfix日常维护

启动postfix

postfix start

停止postfix

postfix stop

重新读取postfix配置文件

postfix reload

立即投递队列中所有邮件(慎用)

postfix flush

查看队列邮件

postqueue -p
mailq
postqueue -p |tail

使用postsuper 来维护队列。

一般是先用mailq查看队列里的邮件,找到对应的id,然后用postsuper -d来删除。

例如id是0EAF3A9B 那么postsuper -d 0EAF3A9B

Q: 删除邮件队列
A: mailq | tail +2 | awk 'BEGIN { RS = "" } / chen@example.org$/ { print $1 }' | tr -d '*!' | postsuper -d -

详细要看mailq和postsuper的用法修复队列以及任何权限错误

postfix check

查看邮件系统日志

tail -f /var/log/maillog 
  • 显示信件列表:postqueue -p

  • 显示信件內容:postcat -q Queue_ID

  • 刪除各別信件:postsuper -d Queue_ID

  • 全部刪除:postsuper -d ALL

  • 扣住信件:postsuper -h Queue_ID

  • 回复:postsuper -H Queue_ID

重新排程:

postsuper -r Queue_ID
postsuper -r ALL

清除信件:

postqueue -f (全部)
postqueue -s 主机名称(个别对象)

要查看Postfix的当前主要配置文件的存放路径:

postconf -n
  • 系统日志:tail -f /var/log/messages

  • 邮件日志:tail -f /var/log/maillog

  • clamd相关:tail -f /var/log/clamav/clamd.log  tail -f /var/log/clamav/freshclam.log

  • maildrop相关:tail -f /var/log/maildrop.log

  • apache相关:tail -f /usr/local/httpd/logs/error_log  tail -f /usr/local/httpd/logs/suexec_log

  • mysql相关:tail -f /usr/local/mysql/data/linux.linux.com.err

  • 测试amavisd:amavisd -d config debug-sa

  • 测试spam:spamassassin -D –lint

  • 测试maildrop:maildrop -V 10 -dtest@test.com

postsuper -d ALL 这样就删除所有邮件啦

Ubuntu安装配置Postfix邮箱服务器

为什么要搭建自己的邮箱服务器呢?你知道希拉里⋅克林顿曾经使用过一个专用的私人邮箱服务器吗?

搭建自己的私人邮箱服务器可以有效的解决邮件的隐私问题。因为只有你,邮箱服务器的管理员,才能看见服务器上的邮件。但是自己搭建邮箱服务器是一个比较麻烦的过程,因为你需要掌握许多许多的知识,使邮箱服务器正常运转。

所以,我把邮箱服务器的搭建分成几个部分来讲,减少小白的痛苦。这篇文章是第1部分,讲解搭建一个非常简易的Postfix邮箱服务器的步骤。Postifx是一个SMTP服务器。SMTP服务器也被称为MTA(message transfer agent)。完成了这篇教程,你就能拥有一个属于自己域名的邮箱地址,比如我的网站邮箱地址是gnu@linuxdashen.com 。并且能用这个邮箱地址向Gmail,Yahoo,QQ,网易等邮箱发送邮件并从这些邮箱服务提供商接收邮件。这篇教程以Ubuntu 14.04服务器作为示例。

一. 关于Postfix

Postfix是一个顶尖的SMTP服务器,也被称为MTA。Postfix负责从其他SMTP服务器接收邮件,将MUA递交的邮件传递给收件人。MUA(mail user agent)就是我们平常使用的Thunderbird,Foxmail,Outlook等邮箱客户端。Postfix程序采用模块化的设计,每一个模块都尽可能以最低的权限运行。这种设计非常有助于安全。Postfix与Unix的结合度非常高。一台Linux服务器的Postfix可以负责多个域名的邮件发送和接收。这篇文章只介绍单个域名的发送和接收。

二. 安装Postfix之前的准备工作

Postfix的原作者是Wietse Venema,他可是一位Unix专家。对于Unix已经提供的功能,Postfix都尽可能不再重复提供。所以,要让Postfix发挥最大功效,我们需要合理地配置好Unix/Linux服务器。

1. 设置正确的主机名(hostname)

一般情况下,Postfix与其他SMTP服务器通信的时候会使用Unix/Linux服务器的主机名来表明自己的身份。主机名可以有两种形式,单个名字和FQDN.

通常,个人电脑使用单个名字来作为主机名。比如,你的Linux系统的主机名可能是linux,Debian, Ubuntu等。FQDN (Fully Qualified Domain Name) 由两个部分组成,节点名和域名。例如,

mail.linuxdashen.com

就是FQDN形式的主机名。mail是节点名,linuxdashen.com是域名。面向互联网的服务器一般使用FQDN形式的主机名。邮箱服务器也应该使用FQDN形式的主机名。FQDN将会出现在smtpd横幅中(smtpd banner),这是Postfix向其他SMTP服务器表明自己身份的方式。

如果你的SMTP服务器不用FQDN来表明自己的身份,那么收件人的SMTP服务器可能会拒收邮件。有些SMTP服务器甚至会查询DNS,验证FQDN是否真的解析为你的服务器IP。不过,在这垃圾邮件漫天飞的年代,这种做法是可以理解的。所以我们必须得正确设置好邮箱服务器的FQDN主机名。

输入下面的命令查看当前的主机名。

hostname -f

如果你的Ubuntu服务器还没有设置好主机名,可以使用hostnamectl来设置。

sudo hostnamectl set-hostname <your-fqdn>

通常邮箱服务器的FQDN主机名为mail.yourdomain.com。

2. 设置好系统时间

邮件里都有一个时间戳(timestamp),这个时间戳就是Postfix根据当前系统时间设置的。这个时间戳也会出现在Postfix的日志里。所以调整好系统时间是非常必要的。

使用date命令查看时区设置以及当前的系统时间。

user@mail:~$ date
Thu Mar 31 06:37:19 BST 2016

在Ubuntu系统上可以使用

sudo dpkg-reconfigure tzdata

命令来调整时区。时区调整后系统时间基本就没问题了。如果你需要保持非常精确的时间,可以使用NTP协议与远程时间服务器保持同步,具体请看这篇文章。

linux系统用命令配置时区并同步系统时间:
https://www.linuxdashen.com/linux%e7%b3%bb%e7%bb%9f%e7%94%a8%e5%91%bd%e4%bb%a4%e9%85%8d%e7%bd%ae%e6%97%b6%e5%8c%ba%e5%b9%b6%e5%90%8c%e6%ad%a5%e7%b3%bb%e7%bb%9f%e6%97%b6%e9%97%b4

3. 为邮箱服务器设置好DNS记录

MX记录

MX记录的作用是告诉全世界的SMTP服务器,你的邮箱服务器mail.yourdomain.com负责yourdomain.com的邮件发送和接收。

MX记录       @      mail.linuxdashen.com

邮箱服务器的常见DNS名字是mail.yourdomain.com。如果一个域名有多个邮箱服务器,那么可以设置多个MX记录,并设置优先级。优先级用数字表示,数字越小表示优先级越高。

A记录

当其他SMTP服务器知道mail.yourdomain.com负责yourdomain.com的邮件发送和接收后,还必须要知道mail.yourdomain.com这台主机的IP才能建立连接并发送邮件。A记录就是将主机名解析成IP地址的一个记录。

mail.linuxdashen.com          

PTR记录

PTR记录也叫做pointer记录,它将IP地址转换成主机名,与A记录刚好相反。这种解析被称为反向DNS解析(rDNS)。

PTR记录可以帮助我们过滤垃圾邮件。很多SMTP服务器会查找对方SMTP服务器的PTR记录,得到一个主机名,然后与对方SMTP声称的主机名作比较,如果两者一致,就接收邮件,反之不接收邮件或放进垃圾箱。为了不让你的邮件被拒收或放进垃圾箱,你应该为你的服务器IP设置PTR记录。

查找一个IP地址的PTR记录的命令为:

dig -x  +short

或者

host 

因为你是从主机商获得服务器的IP,所以你得在主机商那里设置PTR记录(反向DNS解析),而不是在域名注册商那里设置。

做完了以上准备工作,我们就可以安装Postfix了。

三. 安装Postfix

在ubuntu服务器上运行下面的命令:

sudo apt-get update

sudo apt-get install postfix -y

安装过程中会让你选择一种Postfix配置类型。一般情况下,我们需要选择第二种类型:Internet Site。

Postfix

  • No configuration 表示不要做任何配置;
  • Internet Site 表示直接使用本地SMTP服务器发送和接收邮件;
  • Internet with smarthost 表示使用本地SMTP服务器接收邮件,但发送邮件时不直接使用本地SMTP服务器,而是使用第三方smart host来转发邮件;
  • Satellite system 表示邮件的发送和接收都是由第三方smarthost来完成。
  • Local only 表示邮件只能在本机用户之间发送和接收。

在第二个页面System mail name中填入你的域名,也就是邮箱地址@符号后面的域名,比如,我的邮箱地址是gnu@linuxdashen.com,所以我填的是linuxdashen.com。当发件人的域名地址没有指定时,Postfix会自动将这个域名添加到发件人的地址中。

Postfix在安装过程中会生成/etc/postfix/main.cf配置文件。安装完成后Postfix会自动运行。我们可以用下面的命令查看Postfix的版本。

user@mail:~$ sudo postconf mail_version
mail_version = 2.11.0

使用netstat来查看Postfix的监听情况:

sudo netstat -lnpt

Postfix的master进程监听TCP 25号端口。

Postfix

在发送测试邮件之前,我们最好是查看25号端口是否被防火墙或主机商屏蔽。nmap可以帮助我们扫描服务器的开放端口。在你的个人电脑上运行下面的命令。

sudo nmap your-server-ip

Postfix

从图中可以看见我的服务器TCP 25号端口是开放的。如果的输出结果显示25端口被过滤,请查看iptables防火墙设置。如果你的主机商屏蔽了25号端口,给你的主机商提交工单,要求打开25号端口。

四. 发送测试邮件

实际上,现在我们就能用命令行发送和接收邮件了。如果你的服务器有一个用户名是user1,那么这个用户的邮箱地址就是user1@yourdomain.com。你可以发送一封邮件给root用户: root@yourdomain.com。也可以向Gmail,Yahoo,QQ,网易等邮箱用户发送邮件。不过现在我们只能在服务器上用命令行发送和查看邮件。

Postfix在安装时,会同时安装一个sendmail的程序(/usr/sbin/sendmail)。你可以用这个sendmail二进制程序向你的Gmail邮箱发送一封测试邮件。在服务器上输入下面的命令:

echo "test email" | sendmail your-account@gmail.com

这是一条很简单的命令, sendmail从标准输入读取到test email,将test email作为邮件正文,然后发送到Gmail邮箱。现在你可以查看你的Gmail邮箱,应该会看见你的测试邮件。尽管我们没有指明发件人地址,但Postfix会自动将你的域名添加到发送人地址中。你也可以在Gmail中回复这封测试邮件,然后在邮箱服务器上查看是否可以收到Gmail发来的邮件。

每个用户的邮件保存在/var/spool/mail和/var/mail/文件中。如果你不知道收件箱保存在哪里,运行这条命令:

postconf mail_spool_directory

Postfix的收发日志保存在/var/log/mail.log文件中。Postfix本身的运行错误日志保存在/var/log/mail.err文件中。

五. 使用mail程序来发送邮件,查看收件箱

sendmail的功能非常有限,现在让我们来安装一个命令行邮箱客户端。

sudo apt-get install mailutils

使用mail发送邮件的命令为

mail username@gmail.com
user@mail:~$ mail username@gmail.com
Cc: 
Subject: 2nd test email
I'm sending this email using the mail program.

输入主题和正文后,按Ctrl+D来发送邮件。

要查看收件箱,输入mail就行了。

mail

以下是用mail管理收件箱的操作方法。

  • 要查看第一封邮件,输入数字1。如果邮件只显示了一半,按Enter键来显示剩下的消息。
  • 将所有邮件从第一封排序,输入h。
  • 要显示最后一屏邮件,输入h$或z。
  • 阅读下一封邮件,输入n。
  • 删除第一封邮件,输入d 1。
  • 删除第一封,第二封和第四封邮件,输入d 1 2 4。
  • 删除前10封邮件,输入d 1-10。
  • 回复第1封邮件,输入reply 1。
  • 退出mail程序,输入q或x。

如果你按q来退出mail程序,那么已经阅读过的邮件将会从/var/mail/移动到/home//mbox文件中。这意味着其他邮箱客户端将不能阅读这些邮件。如果你不想移动已经阅读的邮件,输入x退出mail程序。

如果需要自动转发邮件,那么在用户的home目录下新建一个.forward文件,在这个文件里输入转发邮件地址,然后保存就行了。注意:用户邮箱不会保留原始邮件。

六. 文章总结

现在,我们在Ubuntu服务器上搭建了一个很简陋的Postfix邮箱服务器。我们可以在服务器上用命令行来发送和阅读邮件。另外如果这台ubuntu服务器上搭建了一个网站,那么PHPMailer等网站程序就能向外发送邮件了。但是这种方式有很多不方便,比如每次发送或查看邮件都要SSH登录服务器,而且只能查看纯文本的邮件,不能阅读HTML邮件。在接下来的文章中,我将介绍如何在我们的个人电脑上使用Thunderbird,outlook等邮箱客户端来发送和阅读邮件,如何从浏览器中登录邮箱服务器以及如何加密我们的邮件, urhh,还有很多其他的高级设置。