使用iredmail部署邮件服务器
0 准备
? 0.0 一个ubuntu server裸机(什么都没安装)
? 0.1 更新源列表 :
? apt-get update
? 0.2 安装 emacs:
? apt-get -y install emacs23
? 0.3 拷贝需要的包
1 配置mail?
? 1.1 ?配置fqdn
? /etc/hostname: mail
? /etc/hosts mail.XXX.com mail localhost localhost.localdomain
? 测试: hostname -f
? 1.2 ?初步安装 大致安装一下
? (因为有3个文件下载不了需要自己手动配置,大致安装好postfix和dovecot)
? 解压:?
? tar jxf iRedMail-0.7.3.tar.bz2
? tar xzf iredmail_packages.tar.gz
? chmod a+x iRedmail.sh
? bash iRedmail.sh?
??
? 1.3 ?安装好后测试smtp(postfix)和imap(dovecot)服务器:
? smtp服务器?
? telnet localhost 25
? ehlo example.com
? auth plain 用户名和密码的base64编码
? mail from: <www@example.com>
? rcpt to: <www@example.com>
? data
? subject: ***
? .
? possible error: 邮件不能发送成功是因为没有开启iredapd, 出错后可以查看syslog
? ps : 获得base64编码
? >> python
? >> import base64
? >> base64.b64encode('www@example.com\0www@example.com\0root')
? >> xxx
? imap服务器
? telnet localhost 110
? user www@example.com
? pass root
? list
??
2 配置iredapd实现邮件列表的控制
? 2.1 ?初始iredapd
? cd /opt/iRedAPD-1.3.6/rc_scripts
? cp iredapd.debian iredapd
? cp iredapd-rr.debian iredapd-rr?
? cp iredapd iredapd-rr /etc/init.d/
? 2.2 配置
? ? ? cp iredapd.ini.sample iredapd.ini ? ? ??
? ? ? cp iredapd-rr.ini.sample iredapd-rr.ini
? ? ? (1) 注释所有的ldap,只使用mysql的
? ? ? (2) backend = mysql?
? ? ? (3) run_as_user=mailserver(一个低权限用户)
? ? ? (4) 修改mysql的用户名和密码
? 2.3 运行iredapd
? /etc/init.d/iredapd start
? /etc/init.d/iredapd-rr start
??
3 配置iRedAdmin
? 3.1 初始化
? cp iRedAdmin-0.1.6.tar.bz2 /usr/share/apache2/
? tar jxf iRedAdmin-0.1.6.tar.bz2
? 3.2 配置
? cp settings.ini.mysql.sample settings.ini
? 配置settings.ini中的mysql用户名密码
? 在mysql中:
? source /usr/share/apache2/iredadmin/docs/samples/iredadmin.sql
? 3.3 测试 ? ? ? ? ? ? ? ? ? ??
? https://****/iredadmin/
4 配置roundcubemail
? 4.1 初始化
? cp roundcubemail-0.5.4.tar.gz /usr/share/apache2/
? tar xzf roundcubemail-0.5.4.tar.gz
? 4.2 配置
? ? ? cd config
? ? ? cp main.inc.php.dist main.inc.php
? ? ? cp db.inc.php.dist db.inc.php
? ? ? 配置mysql链接(db.inc.php):
? ? ? $rcmail_config['db_dsnw'] = 'mysql://root:root@localhost/roundcubemail';
? ? ? 配置(main.inc.php)
? ? ? $rcmail_config['default_host'] = '127.0.0.1';
? ? ? $rcmail_config['smtp_server'] = '127.0.0.1'; ? ? ? ? ? ??
? ? ? $rcmail_config['smtp_user'] = '%u';
? ? ? $rcmail_config['smtp_pass'] = '%p';
? ? ? ? ? ? ? ? ?
? 4.3添加修改密码插件:
? 在roundcubemail的主配置文件中:main.inc.php
? $rcmail_config['plugins'] = array('password');
? cd plugins/password/
? cp config.inc.php config.inc.php.dist
? 1 ?在roundcubemail中添加函数:update_passwd,
? ? ?code:
? ? ?DELIMITER &&
? ? ?CREATE FUNCTION `update_passwd`(pwd varchar(100), usr varchar(100))
? ? ? ?RETURNS int(11)
? ? ? ?BEGIN
? ? ? ? ? ?UPDATE vmail.mailbox SET password=pwd WHERE username=usr LIMIT 1;
? ? ? ? ? ? ? ?RETURN ROW_COUNT();
? ? ? ?END &&
? ? ?DELIMITER ;
? 2 ?配置plugins/password/config.inc.php
? ? ?$rcmail_config['password_query'] = 'SELECT update_passwd(%c, %u)';