2.2、设置数据库
2.2.1、添加mysql用户:
1、使用webmin->mysql数据库服务器->用户权限,添加用户postfix,密码postfix,主机localhost,并设置拥有相应的权限。
2、使用SQL语句添加用户:
#cd /usr/local/bin
#./mysql –D mysql –p
Password:
mysql>INSERT INTO user (host,user,password)
->VALUES (‘localhost’,‘postfix’,’’);
Query OK. I row affected (0.00 sec)
mysql>UPDATA user SET password=password(‘postfix’)
->WHERE user=’postfix’;
Rows matched: 1 Changed: 1 Warnings: 0
mysql>FLUSH PRIVILEGES;
Query OK. 0 rows affected (0.01 sec)
mysql>GRANT select,insert,update on mail.* TO postfix
Query OK. 0 rows affected (0.01 sec)
mysql>exit
2.2.2、向数据库中添加表
#cd /usr/local/bin/
#ee postfix.sql
CREATE DATABASE;
GRANT ALL ON mail.* mail@localhost IDENTIFIED BY “postfix”;
FLUSH PRIVILEGES;
use mail;
CREATE TABLE forward (
username varchar(255) NOT NULL default ‘’, //本机地址
forward_addr varchar(255) default NULL, //转发地址
PRIMARY KEY (username)
) TYPE=MyISAM;
CREATE TABLE transport (
domain varchar(255) NOT NULL default ‘’, //邮件域
transport varchar(icon_cool.gif default NULL, //处理方式
PRIMARY KEY (domain)
) TYPE=MyISAM;
CREATE TABLE users (
username varchar(128) NOT NULL default ‘’, //用户名
domain varchar(128) NOT NULL default ‘’, //邮件域
address varchar(128) NOT NULL default ‘’, //邮件地址
password varchar(128) NOT NULL default ‘’, //用户密码(明文)
uid int(6) NOT NULL default ‘1024’, //uid
gid int(6) NOT NULL default ‘1024’, //gid
home varchar(255) NOT NULL default ‘/’, //home目录
maildir varchar(255) NOT NULL default ‘’, //maildir目录
quota varchar(255) NOT NULL default ‘’, //邮箱容量
mailok tinyint(3) NOT NULL default ‘1’,
bool1 tinyint(3) NOT NULL default ‘1’,
bool2 tinyint(3) NOT NULL default ‘1’,
PRIMARY KEY (address),
UNIQUE KEY address (address),
KEY address_2 (address)
) TYPE=MyISAM;
输入完毕后保存退出。
#./mysql –u postfix –p < postfix.sql
#password:postfix
2.2.3、向表中添加数据
#/usr/local/bin
#./mysql –u postfix –p
password:******
mysql>use mail
mysql>INSERT INTO transport (domain,transport)
->VALUES (’localhost.com’,’virtual:’);
mysql>INSERT INTO users (username,domain,address,password,uid,gid,
home,maildir,quota,mailok,bool1,bool2)
->VALUES (‘test’,’localhost.com’,’test.localhost.com’,
’test’,’1024’,’1024’,’/’,
’/var/postfix_mail/test/Maildir/’,’5000000’,’1’,’1’,’1’);
mysql>exit
3.安装CYRUS-SASL
#tar –zxvf cyrus-sasl-1.5.27
#cd cyrus-sasl-1.5.27
#./configure --with-pwcheck=/var/pwcheck --enable-login
--enable-plain
#make
#make install
#echo /usr/local/lib/ >> /etc/ld.so.conf
#echo /usr/local/lib/mysql/ >> /etc/ld.so.conf
#ldconfig
#cp /usr/local/include/* /usr/include
#cp /usr/local/lib/lib*.* /usr/lib
#ln –s /usr/local/lib/sasl /usr/lib/sasl
#ln –s /usr/local/include/mysql /usr/include/mysql
#ln –s /usr/local/lib/mysql /usr/lib/mysql
在/usr/local/lib/sasl下建立文件smtpd.conf,添加一下内容:
pwcheck_method:mysql
mysql_user:postfix
mysql_passwd:postfix
mysql_host:localhost
mysql_database:mail
mysql_table:users
mysql_uidcol:address
mysql_pwdcol:password
4.安装和设置postfix
4.1、安装postfix
4.4.1、编译/etc/rc.conf,设置sendmail_enable=”NO”
#mv /usr/bin/newaliases /usr/bin/newaliases.OFF
#mv /usr/bin/mailq /usr/bin/mailq.OFF
#mv /usr/sbin/sendmail /usr/sbin/sendmail.OFF
#pw groupadd postfix –g 1024
#pw groupadd postdrop –g 1025
#pw useradd postfix –u 1024 –g postfix
#echo ‘postfix:root’ >> /etc/aliases
4.4.2、安装postfix和相应的quota补丁
#tar zxvf postfix-1.1.11.tar.gz
#patch < postfix-1.1.11_quota_maildirsize.patch
#make –f Makefile.init makefiles ‘CCARGS=-DUSE_SASL_AUTH –DHAS_MYSQL –I/usr/include/mysql’ ‘AUXLIBS=-L/usr/lib/mysql –lmysqlclient –lasal –lz –lm’
#make
#make install 按照默认路径一路回车就可以安装成功postfix,如果出错,在提示“tempdir”时输入:/tmp,这样一般就可以通过。
4.2、设置postfix
postfix默认安装到/etc/postfix目录下,设置文件也在这
#cd /etc/postfix
4.2.1、编译主配置文件main.cf
#ee main.cf 添加如下内容
#Base configure
myhostname = mail.localhost.com //本机的机器名
mydomain = local.com //域名
mynetworks = 127.0.0.0/8 192.168.0.0/16 //允许不经smtp认证能发信的ip段
home_mailbox = Maildir/ //使用的邮箱格式为Maildir/
smtpd_banner = Welcome to localhost.com mail system! //smtp的欢迎信息
#Mysql configure
transport_maps = mysql:/etc/postfix/transport.cf //指定那些域的邮件可以被postfix收下来
virtual_mailbox_base =/ //指定用户邮箱所在的根目录
virtual_uid_maps = mysql:/etc/postfix/ids.cf //指定postfix帐号的ID
virtual_gid_maps = mysql:/etc/postfix/gds.cf //指定postfix组的ID
virtual_mailbox_maps = mysql:/etc/postfix/users.cf //指定用户邮箱的目录
virtual_maps = mysql:/etc/postfix/forward.cf //指定自动转发邮件的设置
#Quota configure
message_size_limit = 5000000 //单个邮件大小的限制
virtual_mailbox_limit = 5000000 //默认的邮箱大小
virtual_mailbox_limit_maps = mysql:/etc/postfix/quota.cf //每个用户的邮箱大小
virtual_mailbox_limit_override = yes //是否允许覆盖默认的邮箱大小
#smtp configure
smtpd_sasl_auth_enable = yes
smtpd_sasl_local_domain = $myhostname
smtpd_recipient_restrictions = permit_mynetworks permit_sasl_authenticated permit_auth_destination reject
smtpd_sasl_security_options = noanonymous
smtpd_client_restrictions = permit_sasl_authenticated
inet_interfaces = all //监听所有端口
inet_interfaces = 192.168.80.21 //是外面的用户也可以发送邮件
4.2.2、查看master.cf文件必须包含下面一行
virtual unix - n n - - virtual
4.2.3、编译transport.cf
#touch transport.cf
#ee transport.cf 添加如下内容
user = postfix
password = postfix
dbname = mail
table = transport
select_field = transport
where_field = domain
hosts = localhost
4.2.4、编译ids.cf
#touch ids.cf
#ee ids.cf
user = postfix
password = postfix
dbname = mail
table = users
select_field = uid
where_field = address
hosts = localhost
4.2.5、编译gds.cf
#touch gds.cf
#ee gds.cf
user = postfix
password = postfix
dbname = mail
table = users
select_field = gid
where_field = address
hosts = localhost
4.2.6、编译forward.cf
#touch forward.cf
#ee forward.cf
user = postfix
password = postfix
dbname = mail
table = forward
select_field = forward_addr
where_field = username
hosts = localhost
4.2.7、编译users.cf
#touch users.cf
#ee users.cf
user = postfix
password = postfix
dbname = mail
table = users
select_field = maildir
where_field = address
hosts = localhost
4.2.8、编译quota.cf
#touch quota.cf
#ee quota.cf
user = postfix
password = postfix
dbname = mail
table = users
select_field = quota
where_field = address
hosts = localhost
4.3、启动postfix
#/usr/sbin/postfix start
postfix/postfix-script: starting the Postfix mail system
#echo “/usr/sbin/postfix start” >> /etc/rc.local
#telnet localhost 25
Connected to localhost.localhost.com.
Escape character is ‘^]’.
220 Welcome to localhost mail system!
4.4、测试postfix
4.4.1、建立mail邮件存放目录
#cd /var
#mkdir postfix_mail
#chown –R postfix:postfix /var/postfix_mail
4.4.2、使用客户端发邮件
此时可以使用客户端的foxmail或者outlook向用户test.localhost.com发送邮件,然后到/var/postfix/test/Maildir/下查看邮件,如果能收到说明SMTP已经工作正常了,如果有问题仔细检查自己的每个步骤。
5.安装设置courier-imap
5.1、安装courier-imap
#cd /usr/ports/mail/courier-imap
#make
#cd work/courier-imap-1.5.3
#./configure –with-db=db –without-socks –disable-root-check
#make
#make install
#/usr/lib/courier-imap/libexec/authlib/authdaemon start
#echo “/usr/lib/courier-imap/libexec/authlib/authdaemon start” >> /etc/rc.local
5.2、添加用户
#cd /usr/local/bin
#./mysql –D mysql –p
password:*******
mysql>INSERT INTO user (host,user,password)
->VALUES (‘localhost’,’courier’,’’);
mysql>UPDATA user SET password=password(‘haha’)
->WHERE user=’courier’;
mysql>FLUSH PRIVILEGES;
mysql>GRAN select,insert,update on mail.* TO courier;
mysql>exit
5.3、设置courier-imap
#cd /usr/lib/courier-imap/etc
#cp authdaemonrc.dist authdaemonrc
#cp authmysqlrc.dist authmysqlrc
#cp imapd.dist imapd
#cp imapd-ssl.dist imapd-ssl
#cp pop3d.dist pop3d
#cp pop3d-ssl pop3d-ssl
#ee pop3d
prefix=/usr/lib/courier-imap
exec_prefix=/usr/lib/courier-imap
sbindir=”/usr/lib/courier-imap/sbin”
PIDFILE=/var/run/pop3d.pid
MAXDAEMONS=40
MAXPERIP=4
AUTHMODULES=”authdaemon”
AUTHMODULES_ORIG=”authdaemon”
POP3AUTH=””
POP3AUTH_ORIG=”LOGIN CRAM-MD5 CRAM-SHA1”
POP3AUTH_TLS=””
POP3AUTH_TLS_ORIG=”LOGIN PLAIN”
PORT=110
ADDRESS=0
TCPDOPTS=”-nodnslookup -noidentlookup”
POP3DSTART=YES
#ee imapd
IMAPDSTART=YES
#ee authdaemonrc
authmodulelist=”authmysql authpam”
authmodulelistorig=”authcustom authcram authuserdb authmysql authpam”
daemons=5
version=”authdaemond.mysql”
authdaemonvar=”/usr/lib/courier-imap/var/authdaemon”
#ee authmysqlrc
MYSQL_SERVER localhost
MYSQL_USERNAME courier
MYSQL_PASSWORD haha
MYSQL_SOCKET /tmp/mysql.sock
MYSQL_PORT 3306
MYSQL_OPT 0
MYSQL_DATABASE mail
MYSQL_USER_TABLE users
#MYSQL_CRYPT_PWFIELD password
MYSQL_CLEAR_PWFIELD password
MYSQL_UID_FIELD uid
MYSQL_GID_FIELD gid
MYSQL_LOGIN_FIELD address
MYSQL_HOME_FIELD home
MYSQL_NAME_FIELD username
MYSQL_MAILDIR_FIELD maildir
MYSQL_QUOTA_FIELD quota
MYSQL_WHERE_CLAUSE mailok=1
#cd ..
#ln -s /usr/lib/courier-imap/libexec/imapd.rc imapd
#ln -s /usr/lib/courier-imap/libexec/pop3d.rc pop3d
#./imapd start
#echo “/usr/lib/courier-imap/imap start” >> /etc/rc.local
#./pop3d start
#echo “/usr/lib/courier-imap/pop3 start” >> /etc/rc.local
#netstat –an | grep LISTEN
tcp4 0 0 *:110 *:* LISTEN
tcp46 0 0 *:110 *:* LISTEN
tcp4 0 0 *:143 *.* LISTEN
tcp46 0 0 *.143 *.* LISTEN
#telnet localhost 110
Trying 127.0.0.1...
Connected to localhost.cw-isquare.com.
Escape character is ‘^]’.
+OK Hello there
#quit
#telnet localhost 143
*OK Courier-IMAP ready. Copyright 1998-2002 Double Precision, Inc. See COPYING for distribution information.
#quit
5.安装设置sqwebmail
5.1、安装sqwebmail-3.5.0-cn.tar.gz
#tar zxvf sqwebmail-3.5.0.tar.gz
#cd sqwebmail-3.5.0
#./configure --without-authpam –with-db=db --enable-webpass=no --without-authpwd --without-authshadow
#make configure-check
#make
#make install-strip
#make install-configure
#/usr/local/share/sqwebmail/libexec/authlib/authdaemond start
#echo “/usr/local/share/sqwebmail/libexec/authlib/authdaemond start” >> /etc/rc.local
5.2、配置sqwebmail-3.5.0
5.2.1、安装apache
#tar apache_1.3.22.tar.gz
#cd apache_1.3.22
#./configure –prefix=/usr/local/apache
#make
#make install
5.2.2、设置sqwebmail
#cd /usr/local/share/sqwebmail
#ee authdaemonrc
authmodulelist=”authmysql authpam”
authmodulelistorig=”authcustom authcram authuserdb authmysql authpam”
daemons=5
version=”authdaemond.mysql”
authdaemonvar=”/usr/local/share/sqwebmail/var/authdaemon”
#ee authmysqlrc
MYSQL_SERVER localhost
MYSQL_USERNAME courier
MYSQL_PASSWORD haha
MYSQL_SOCKET /tmp/mysql.sock
MYSQL_PORT 3306
MYSQL_OPT 0
MYSQL_DATABASE mail
MYSQL_USER_TABLE users
#MYSQL_CRYPT_PWFIELD password
MYSQL_CLEAR_PWFIELD password
MYSQL_UID_FIELD uid
MYSQL_GID_FIELD gid
MYSQL_LOGIN_FIELD address
MYSQL_HOME_FIELD home
MYSQL_NAME_FIELD username
MYSQL_MAILDIR_FIELD maildir
MYSQL_QUOTA_FIELD quota
MYSQL_WHERE_CLAUSE mailok=1
5.2.3、测试sqwebmail-3.5.0
在客户端的浏览器的地址栏输入
http://mail.localhost.com/cgi-bin/sqwebmail
输入用户名和密码就可以登录进去收发邮件了。
注意:用户名一定要输入全称,也就是连域名一起输入。
5.2.4、设置apache页面跳转
#cd /usr/local/apache/htdocs
#touch index.html
#ee index.html
<meta http-equiv=”refresh” content=”0;URL=http://mail.localhost
.com/cgi-bin/sqwebmail?index=1”>
现在就可以直接在IE的地址栏输入:
http://mail.localhost.com
来访问sqwebmail了
这篇文章没有加入smtp认证,上次有个朋友在帖子里说过加认证的方法,由于没有时间,所以我就没有试。还有没有邮件列表的问题,我找不到解决的方法,如果有朋友看到这篇文章请把smtp认证和邮件列表功能补充一下,这要就比较完整了。在此我先表示感谢~
自由广告区 |
分类导航 |
邮件新闻资讯: IT业界 | 邮件服务器 | 邮件趣闻 | 移动电邮 电子邮箱 | 反垃圾邮件|邮件客户端|网络安全 行业数据 | 邮件人物 | 网站公告 | 行业法规 网络技术: 邮件原理 | 网络协议 | 网络管理 | 传输介质 线路接入 | 路由接口 | 邮件存储 | 华为3Com CISCO技术 | 网络与服务器硬件 操作系统: Windows 9X | Linux&Uinx | Windows NT Windows Vista | FreeBSD | 其它操作系统 邮件服务器: 程序与开发 | Exchange | Qmail | Postfix Sendmail | MDaemon | Domino | Foxmail KerioMail | JavaMail | Winwebmail |James Merak&VisNetic | CMailServer | WinMail 金笛邮件系统 | 其它 | 反垃圾邮件: 综述| 客户端反垃圾邮件|服务器端反垃圾邮件 邮件客户端软件: Outlook | Foxmail | DreamMail| KooMail The bat | 雷鸟 | Eudora |Becky! |Pegasus IncrediMail |其它 电子邮箱: 个人邮箱 | 企业邮箱 |Gmail 移动电子邮件:服务器 | 客户端 | 技术前沿 邮件网络安全: 软件漏洞 | 安全知识 | 病毒公告 |防火墙 攻防技术 | 病毒查杀| ISA | 数字签名 邮件营销: Email营销 | 网络营销 | 营销技巧 |营销案例 邮件人才:招聘 | 职场 | 培训 | 指南 | 职场 解决方案: 邮件系统|反垃圾邮件 |安全 |移动电邮 |招标 产品评测: 邮件系统 |反垃圾邮件 |邮箱 |安全 |客户端 |