1,Extmail概述
ExtMail Solution 是一个基于优秀开源软件的电子邮件系统解决方案,核心部件包括了Postfix、Amavisd-new、ClamAV、ExtMail、ExtMan、Courier系列软件。是一个功能相对比较齐全的免费电子邮件系统。 而其中Extmail 是一个以perl语言编写,面向大容量/ISP级应用,免费的高性能Webmail软件,主要包括ExtMail、Extman两个部分的程序套件。ExtMail套件用于提供从浏览器中登录、使用邮件系统的Web操作界面,而Extman套件用于提供从浏览器中管理邮件系统的Web操作界面。 2,Extmail工作原理Extmail的核心部分是postfix,是一种web页面,可以创建账号,可以收发邮件。extman可以账号注册。账号存放在mysql里面。postfix发信件,dovecot收信件。利用outlook收信件(docecot)和发信件(postfix)都要通过mysql查询。发信件(postfix)要提取mysql账号信息要通过courier-authlib。是基于虚拟帐号的邮件系统。 配置准备: 修改主机名为mail.aolens.cn 在DNS上解析mail.aolens.cn - @ MX mail.aolens.cn
- mail A ip地址
3,Extmail搭建 3.1 安装依赖 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
| [iyunv@node2 ~]# yum install httpd mysql mysql-server mysql-devel openssl-devel dovecot perl-DBD-MySQL tcl tcl-devel libart_lgpl libart_lgpl-devel libtool-ltdl libtool-ltdl-devel expect
[iyunv@node2 ~]# yum groupinstall "Development Libraries” “Development Tools"
root@node2 ~]# service httpd start
正在启动 httpd:httpd: Could not reliably determine the server's fully qualified domain name, using node2.aolens.cn for ServerName
[确定]
[iyunv@node2 ~]# service mysqld start
初始化 MySQL 数据库: Installing MySQL system tables...
[确定]
正在启动 mysqld: [确定]
[iyunv@node2 ~]# mysqladmin password aolens #为数据库设置密码
3.2 安装postfix
[iyunv@node2 ~]# rpm -qa postfix
postfix-2.6.6-2.2.el6_1.x86_64
[iyunv@node2 ~]# rpm -e postfix --nodeps
[iyunv@node2 ~]# id postfix
uid=89(postfix) gid=89(postfix) 组=89(postfix),12(mail)
[iyunv@node2 ~]# userdel postfix
[iyunv@node2 ~]# groupdel postfix
[iyunv@node2 ~]# grep postfix /etc/passwd
[iyunv@node2 ~]# rm -rf /var/spool/postfix
[iyunv@node2 ~]# groupadd -g 2525 postfix
[iyunv@node2 ~]# useradd -g postfix -u 2525 -s /sbin/nologin -M postfix
[iyunv@node2 ~]# groupdel postdrop
[iyunv@node2 ~]# groupadd -g 2526 postdrop
[iyunv@node2 ~]# useradd -g postdrop -u 2526 -s /sbin/nologin -M postdrop
[iyunv@node2 ~]# grep post* /etc/passwd
postfix:x:2525:2525::/home/postfix:/sbin/nologin
postdrop:x:2526:2526::/home/postdrop:/sbin/nologin
|
postfix版本:postfix-3.2-20160327
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
| [iyunv@node2 ~]# wget ftp://ftp.cuhk.edu.hk/pub/packag ... 3.2-20160327.tar.gz
[iyunv@node2 ~/postfix-3.2-20160327]# yum install cyrus-sasl*
SASL:Simple Authintication Secure Layer简单认证安全层,用来认证邮箱账号的
[iyunv@node2 ~/postfix-3.2-20160327]# 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 -lm -L/usr/lib64/sasl2 -lsasl2 -lssl -lcrypto’
[iyunv@node2 ~/postfix-3.2-20160327]# make && make install && echo ok
按照以下提示输入相关路径,省略表示采用默认值
install_root: [/] /
tempdir: [/root/postfix-3.2-20160327] /tmp
config_directory: [/etc/postfix] /etc/postfix
command_directory: [/usr/sbin] /usr/sbin
daemon_directory: [/usr/libexec/postfix]
data_directory: [/var/lib/postfix]
html_directory: [no] /var/www/postfix_html
mail_owner: [postfix]
mailq_path: [/usr/bin/mailq]
manpage_directory: [/usr/local/man]
queue_directory: [/var/spool/postfix]
readme_directory: [no]
sendmail_path: [/usr/sbin/sendmail]
setgid_group: [postdrop]
shlib_directory: [no]
meta_directory: [/etc/postfix]
[iyunv@node2 ~/postfix-3.2-20160327]# newaliases
newaliases: warning: smtputf8_enable is true, but EAI support is not compiled in
postalias: warning: smtputf8_enable is true, but EAI support is not compiled in
[iyunv@node2 /media]# mkdir postfix2.6
[iyunv@node2 /media]# cd postfix2.6/
[iyunv@node2 /media/postfix2.6]# wget http://mirrors.sohu.com/centos/6 ... -6.el6_5.x86_64.rpm
[iyunv@node2 /media/postfix2.6]# rpm2cpio postfix-2.6.6-6.el6_5.x86_64.rpm |cpio -id
19862 块
[iyunv@node2 /media/postfix2.6]# ls *
postfix-2.6.6-6.el6_5.x86_64.rpm
etc:
pam.d postfix rc.d sasl2
usr:
bin lib libexec sbin share
var:
lib spool
|
#创建sysv脚本
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
| [iyunv@node2 /media/postfix2.6/etc/rc.d/init.d]# cp -p postfix /etc/init.d/
[iyunv@node2 ~]# chown -R postfix /var/lib/postfix
[iyunv@node2 ~]# service postfix start
启动 postfix: [确定]
[iyunv@node2 ~]# ss -tnlp|grep 25
LISTEN 0 100 *:25 *:* users:(("master",55347,13))
[iyunv@node2 ~]# chkconfig --add postfix
[iyunv@node2 ~]# chkconfig postfix on
[iyunv@node2 ~]# vim /etc/postfix/main.cf
#添加下列参数
myhostname = mail.aolens.cn
mydomain = aolens.cn
myorigin = aolens.cn #邮件地址伪装伪装mail.aolens.cn为aolens.cn
inet_interfaces = all
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain #所有目标邮件为以上的就是本机,不用中继了
mynetworks = 192.168.1.0/24,127.0.0.0/8
|
##这里注意一下,我192.168.1.0/24开始的时候写成192.168.1.129/24 导致rcpt to:.. 一直453错误。 使用以下命令验正postfix是否支持cyrus风格的sasl认证,如果您的输出为以下结果,则是支持的: 1
2
3
4
5
6
7
8
9
| [iyunv@mail ~]# service saslauthd start
正在启动 saslauthd: [确定]
[iyunv@mail ~]# postconf -a
cyrus
dovecot
|
postconf命令:配置postfix - -d:显示默认的配置
- -n:显示修改的配置
- -m:显示所有所支持的查找表类型
- -a:显示支持的SASL客户端插件类型
- -e:PARMATER=VALUE:更改某参数配置信息,并保存至main.cf文件中
smtp状态码: - 1XX:
- 2XX:正确信息
- 3XX:当前信息没有结束
- 4XX:暂时性错误
- 5XX:永久性错误
smtp:协议命令 - helo (smtp协议)
- ehlo (esmtp协议)
- mail from: 邮件发送人
- rcpt to: 邮件接收人
- date 邮件内容
- Subject: 邮件标题
- . 邮件结束符
alias:邮件别名 abc@abc.com:efg@efg.com 法网abc的其实会发到efg 使用newaliases来生成/etc/aliases.db 验证postfix是否安装OK 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
| [iyunv@mail ~]# useradd test
[iyunv@mail ~]# telnet localhost 25
Trying ::1...
telnet: connect to address ::1: Connection refused
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
220 Welcome to our mail.aolens.cn ESMTP,Warning: Version not Available!
helo
501 Syntax: HELO hostname
helo localhost
250 mail.aolens.cn
mail from:aolens@aolens.cn
250 2.1.0 Ok
rcpt to:test
250 2.1.5 Ok
data
354 End data with <CR><LF>.<CR><LF>
Subject:aaa
aaaaaaa
.
250 2.0.0 Ok: queued as 2B78580CCB
quit
221 2.0.0 Bye
Connection closed by foreign host.
[iyunv@mail ~]# vim /var/spool/mail/test
From aolens@aolens.cn Wed May 11 10:24:45 2016
Return-Path: <aolens@aolens.cn>
X-Original-To: test
Delivered-To: test@mail.aolens.cn
Received: from localhost (localhost [127.0.0.1])
by mail.aolens.cn (Postfix) with SMTP id 2B78580CCB
for <test>; Wed, 11 May 2016 10:24:25 +0800 (CST)
Subject:aaa
Message-Id: <20160511022433.2B78580CCB@mail.aolens.cn>
Date: Wed, 11 May 2016 10:24:25 +0800 (CST)
From: aolens@aolens.cn
aaaaaaa
|
我们发现在邮件投递目录里对应的用户中有我们发送过来的邮件。这就说明发送成功了
|