extmail mysql数据库 重启_Extmail邮件服务器centos搭建(一)(示例代码)

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 安装依赖[[email protected] ~]# 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

[[email protected] ~]# yum groupinstall "Development Libraries” “Development Tools"

[email protected] ~]# service httpd start

正在启动 httpd:httpd: Could not reliably determine the server‘s fully qualified domain name, using node2.aolens.cn for ServerName

[确定]

[[email protected] ~]# service mysqld start

初始化 MySQL 数据库: Installing MySQL system tables...

[确定]

正在启动 mysqld:                                          [确定]

[[email protected] ~]# mysqladmin password aolens    #为数据库设置密码

3.2 安装postfix

[[email protected] ~]# rpm -qa postfix

postfix-2.6.6-2.2.el6_1.x86_64

[[email protected] ~]# rpm -e postfix --nodeps

[[email protected] ~]# id postfix

uid=89(postfix) gid=89(postfix) 组=89(postfix),12(mail)

[[email protected] ~]# userdel postfix

[[email protected] ~]# groupdel postfix

[[email protected] ~]# grep postfix /etc/passwd

[[email protected] ~]# rm -rf /var/spool/postfix

[[email protected] ~]# groupadd -g 2525 postfix

[[email protected] ~]# useradd -g postfix -u 2525 -s /sbin/nologin -M postfix

[[email protected] ~]# groupdel postdrop

[[email protected] ~]# groupadd -g 2526 postdrop

[[email protected] ~]# useradd -g postdrop -u 2526 -s /sbin/nologin -M postdrop

[[email protected] ~]# 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[[email protected] ~]# wget ftp://ftp.cuhk.edu.hk/pub/packages/mail-server/postfix/experimental/postfix-3.2-20160327.tar.gz

[[email protected] ~/postfix-3.2-20160327]# yum install cyrus-sasl*

SASL:Simple Authintication Secure Layer简单认证安全层,用来认证邮箱账号的

[[email protected] ~/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’

[[email protected] ~/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]

[[email protected] ~/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

[[email protected] /media]# mkdir postfix2.6

[[email protected] /media]# cd postfix2.6/

[[email protected] /media/postfix2.6]# wget http://mirrors.sohu.com/centos/6.7/os/x86_64/Packages/postfix-2.6.6-6.el6_5.x86_64.rpm

[[email protected] /media/postfix2.6]# rpm2cpio postfix-2.6.6-6.el6_5.x86_64.rpm |cpio -id

19862 块

[[email protected] /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脚本[[email protected] /media/postfix2.6/etc/rc.d/init.d]# cp -p postfix /etc/init.d/

[[email protected] ~]# chown -R postfix /var/lib/postfix

[[email protected] ~]# service postfix start

启动 postfix:                                             [确定]

[[email protected] ~]# ss -tnlp|grep 25

LISTEN     0      100                       *:25                       *:*      users:(("master",55347,13))

[[email protected] ~]# chkconfig --add postfix

[[email protected] ~]# chkconfig postfix on

[[email protected] ~]# 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认证,如果您的输出为以下结果,则是支持的:[[email protected] ~]# service saslauthd start

正在启动 saslauthd:                                       [确定]

[[email protected] ~]# 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:邮件别名

使用newaliases来生成/etc/aliases.db

验证postfix是否安装OK[[email protected] ~]# useradd test

[[email protected] ~]# 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:[email protected]

250 2.1.0 Ok

rcpt to:test

250 2.1.5 Ok

data

354 End data with .

Subject:aaa

aaaaaaa

.

250 2.0.0 Ok: queued as 2B78580CCB

quit

221 2.0.0 Bye

Connection closed by foreign host.

[[email protected] ~]# vim /var/spool/mail/test

From [email protected]  Wed May 11 10:24:45 2016

Return-Path: 

X-Original-To: test

Delivered-To: [email protected]

Received: from localhost (localhost [127.0.0.1])

by mail.aolens.cn (Postfix) with SMTP id 2B78580CCB

for ; Wed, 11 May 2016 10:24:25 +0800 (CST)

Subject:aaa

Message-Id: 

Date: Wed, 11 May 2016 10:24:25 +0800 (CST)

From: [email protected]

aaaaaaa

我们发现在邮件投递目录里对应的用户中有我们发送过来的邮件。这就说明发送成功了

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值