第五章 配置POSTFIX
#ee /usr/local/etc/postfix/main.cf;在最后加入:
#======= BASE ==============
myhostname = mail.chinake.com //本机机器名
mydomain = chinake.com //本机域名
home_mailbox = Maildir/ //邮件的存储方式
mydestination = $myhostname $mydomain //收信域名
local_recipient_maps = //不投递本地系统帐号邮件
mynetworks = 127.0.0.1, 192.168.0.0/24 //信任的,无须SMTP认证的地址范围
alias_maps = hash:/etc/aliases //别名
alias_database = hash:/etc/aliases //别名数据
local_transport = virtual //本地邮件的投递方式,也可以使用maildrop
virtual_transport = virtual //虚拟用户的投递方式,也可以使用maildrop
virtual_mailbox_base = /usr/local/vmail //邮件存储的根目录
virtual_gid_maps = static:80 //虚拟用户的ID
virtual_uid_maps = static:80 //虚拟用户组的ID
virtual_minimum_uid = 80 //虚拟用户的最小ID
#============ ldap mailbox ============
#virtual_mailbox_domains = hash:/usr/local/etc/postfix/transport //虚拟域名,由于只有一个域名,可以不用。
virtual_mailbox_maps = ldap:mailuser //虚拟域邮箱
mailuser_timeout = 10 //超时设置
mailuser_server_host = localhost //与mysql差不多,就是如何去找用户
mailuser_server_port = 389
mailuser_search_base = ou=mail,dc=chinake,dc=com
mailuser_query_filter = (&(mail=%s)(userStatus=1)) //查询语句
mailuser_result_attribute = mailMessageStore
mailuser_bind = yes
mailuser_bind_dn = cn=kunmail,ou=admin,dc=chinake,dc=com
mailuser_bind_pw = 2320419
mailuser_version = 3
#============== ldap Quota ============
message_size_limit = 5242880
virtual_mailbox_limit_size = 5242880
virtual_mailbox_limit_override=yes
#virtual_mailbox_limit_inbox = no
virtual_maildir_extended = yes
virtual_create_maildirsize = yes
virtual_mailbox_limit_maps = ldap:mailquota
mailquota_timeout = 10
mailquota_server_host = localhost
mailquota_server_port = 389
mailquota_search_base = ou=mail,dc=chinake,dc=com
mailquota_query_filter = (mail=%s)
mailquota_result_attribute = mailQuota
mailquota_bind = yes
mailquota_bind_dn = cn=kunmail,ou=admin,dc=chinake,dc=com
mailquota_bind_pw = 2320419
mailquota_version = 3
#============== SASL ================
smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noanonymous
broken_sasl_auth_clients = yes
smtpd_recipient_restrictions = permit_sasl_authenticated permit_auth_destination reject
#smtpd_sasl_local_domain = $mydomain
smtpd_client_restrictions = permit_sasl_authenticated
#============ banner =============
smtpd_banner = Chinke Mail System
多域名直接修改:/usr/local/etc/postfix/transport
#ee /usr/local/etc/postfix/transport
chinake.com virtual:
test.com virtual:
#postmap /usr/local/etc/postfix/transport
第六章 测试
1、测试courier-pop3
手动建立邮件用户目录
mkdir -p /usr/local/vmail/chinake.com/test
maildirmake /usr/local/vmail/chinake.com/test/Maildir
chown -R /usr/local/vmail
chmod -R 700 /usr/local/vmail
#telnet localhost 110
Trying ::1...
Connected to localhost.chinake.com.
Escape character is '^]'.
+OK Hello there.
user test@chinake.com
+OK Password required.
pass test
+OK logged in.
Ctrl+]退出。
如果有出错,请查看/var/log/maillog文件的输出。
2、测试postfix
认证测试:
安装p5-MIME-Base64
# cd /usr/ports/converters/p5-MIME-Base64/
# make install clean
# perl -MMIME::Base64 -e 'print encode_base64("test\@chinake.com");'
dGVzdEBjaGluYWtlLmNvbQ==
# perl -MMIME::Base64 -e 'print encode_base64("test");'
dGVzdA==
#telnet localhost 25
Trying ::1...
telnet: connect to address ::1: Connection refused
Trying 127.0.0.1...
Connected to localhost.chinake.com.
Escape character is '^]'.
220 Chinke Mail System
ehlo mail
250-mail.chinake.com
250-PIPELINING
250-SIZE 5242880
250-VRFY
250-ETRN
250-AUTH LOGIN PLAIN
250-AUTH=LOGIN PLAIN
250 8BITMIME
auth login
334 VXNlcm5hbWU6
dGVzdEBjaGluYWtlLmNvbQ==
334 UGFzc3dvcmQ6
dGVzdA==
235 Authentication successful
如果认证不成功,请查看/var/log/maillog文件,如果提示:
SASL authentication failure: cannot connect to Courier authdaemond: Permission denied
则可能是这一步没有做:
#chmod +x /var/run/authdaemond
如果提示与ldap有关,请仔细检查main.cf文件,注意每次修改后,都要
#postfix reload
发信测试:
#echo "hello" |mail test@chinake.com
成功后/var/log/maillog显示:
May 25 23:46:02 mail postfix/pickup[369]: A57521BB: uid=0 from=<root>
May 25 23:46:02 mail postfix/cleanup[928]: A57521BB: message-id=<20050525154602.A57521BB@mail.chinake.com>
May 25 23:46:02 mail postfix/qmgr[272]: A57521BB: from=<root@mail.chinake.com>, size=285, nrcpt=1 (queue active)
May 25 23:46:03 mail postfix/virtual[930]: A57521BB: to=<test@chinake.com>, relay=virtual,delay=1, status=sent (delivered to maildir)
May 25 23:46:03 mail postfix/qmgr[272]: A57521BB: removed
第七章 安装WEBMAIL
我们使用小松鼠WEBMAIL,它使用IMAP方式,所以需要启动courier-imap-imapd。
#ee /etc/rc.conf;
添加:
courier_imap_imapd_enable=”YES”
启动imapd:
/usr/local/etc/rc.d/courier-imap-imapd.sh start;
安装小松鼠WEBMAIL:
#cd /usr/ports/mail/squirrelmail/;
#ee Makefile;
将默认的安装路径www/修改为:www/data/
#make install clean
配置小松鼠WEBMAIL:
#cd /usr/local/www/data/squirrelmail
#./configure
1. Organization Preferences //修改组织特性,可以不改
2. Server Settings //修改域名,必须要改
3. Folder Defaults //可以将INDEX.XXXX,改成相应的INDEX.垃圾箱、发件箱、草稿箱
4. General Options
5. Themes
6. Address Books
7. Message of the Day (MOTD)
8. Plugins
9. Database
10. Languages //可以将语言改为zh_CH,编码改为GB2312
D. Set pre-defined settings for specific IMAP servers
C Turn color on
S Save data
Q Quit
先存盘,后退出,也可以直接修改config/config.php文件。
使用它去登录吧。
关于新增用户,目前可以这样做,在openldap中添加新用户记录,然后给该新用户发一欢迎信,则courier就会自动建立好用户的邮箱目录,产生相对应的Maildir/。
附件:
1、kunmail.schema
# kunmail-ldap v3 directory schema
# written by hefish@cz8.net
# Attribute Type Definitions
attributetype ( 1.3.6.1.4.1.7914.1.2.1.1 NAME 'userNo'
DESC 'id of the user on the mailsystem'
EQUALITY integerMatch
SYNTAX 1.3.6.1.4.1.1466.115.121.1.27{32}
SINGLE-VALUE )
attributetype ( 1.3.6.1.4.1.7914.1.2.1.2 NAME 'userName'
DESC 'name of the user on the mailsystem'
EQUALITY caseIgnoreIA5Match
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{64}
SINGLE-VALUE )
attributetype ( 1.3.6.1.4.1.7914.1.2.1.3 NAME 'userUid'
DESC 'UID of the user on the mailsystem'
EQUALITY integerMatch
SYNTAX 1.3.6.1.4.1.1466.115.121.1.27{32}
SINGLE-VALUE )
attributetype ( 1.3.6.1.4.1.7914.1.2.1.4 NAME 'userGid'
DESC 'GID of the user on the mailsystem'
EQUALITY integerMatch
SYNTAX 1.3.6.1.4.1.1466.115.121.1.27{32}
SINGLE-VALUE )
attributetype ( 1.3.6.1.4.1.7914.1.2.1.5 NAME 'userHome'
DESC 'home of user in mail system'
EQUALITY caseExactMatch
SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{1024}
SINGLE-VALUE )
attributetype ( 1.3.6.1.4.1.7914.1.2.1.6 NAME 'userMaildir'
DESC 'maildir of user'
SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{1024}
SINGLE-VALUE )
attributetype ( 1.3.6.1.4.1.7914.1.2.1.7 NAME 'userQuota'
DESC 'The amount of space the user can use until all further messages get bounced.'
SYNTAX 1.3.6.1.4.1.1466.115.121.1.44{32}
SINGLE-VALUE )
attributetype ( 1.3.6.1.4.1.7914.1.2.1.8 NAME 'userClearpw'
DESC 'clear password of the user on the mailsystem'
EQUALITY caseExactMatch
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{32}
SINGLE-VALUE )
attributetype ( 1.3.6.1.4.1.7914.1.2.1.9 NAME 'userFullname'
DESC 'full name of user'
SYNTAX 1.3.6.1.4.1.1466.115.121.1.40{64}
SINGLE-VALUE )
attributetype ( 1.3.6.1.4.1.7914.1.2.1.10 NAME 'userActive'
DESC 'The status of a user account'
ORDERING integerOrderingMatch
SYNTAX 1.3.6.1.4.1.1466.115.121.1.27
SINGLE-VALUE )
attributetype ( 1.3.6.1.4.1.7914.1.2.1.11 NAME 'userMailReplyText'
DESC 'A reply text for every incoming message'
SUBSTR caseIgnoreSubstringsMatch
SYNTAX 1.3.6.1.4.1.1466.115.121.1.44{4096}
SINGLE-VALUE )
attributetype ( 1.3.6.1.4.1.7914.1.2.1.12 NAME 'userRegisterDate'
DESC 'timestamp of user registration'
SYNTAX 1.3.6.1.4.1.1466.115.121.1.27
SINGLE-VALUE )
attributetype ( 1.3.6.1.4.1.7914.1.2.1.13 NAME 'userExpireDate'
DESC 'timestamp of user mailbox expiration'
SYNTAX 1.3.6.1.4.1.1466.115.121.1.27
SINGLE-VALUE )
# Object Class Definitions
objectclass ( 1.3.6.1.4.1.7914.1.2.2.1 NAME 'kunmailUser'
DESC 'KunMail-LDAP User' SUP top STRUCTURAL
MUST ( userNo $ userName $ cn $ userUid $ userGid )
MAY ( userMaildir $ userHome $ userClearpw $ userQuota $ userFullname $ userMailReplyText $ userActive $ userRegisterDate $ userExpireDate ) )
2、mail.schema
# mail-ldap v3 directory schema
# written by liut
# This schema depends on:
# - core.schema
# - cosine.schema
# - inetorgperson.schema
# - nis.schema
# - misc.schema
# Attribute Type Definitions
attributetype ( 1.3.6.1.4.1.7914.1.2.1.3 NAME 'mailMessageStore'
DESC 'Path to the maildir/mbox on the mail system'
EQUALITY caseExactIA5Match
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
SINGLE-VALUE )
attributetype ( 1.3.6.1.4.1.7914.1.2.1.4 NAME 'mailQuota'
DESC 'The amount of space the user can use until all further messages get bounced.'
SYNTAX 1.3.6.1.4.1.1466.115.121.1.44{32}
SINGLE-VALUE )
attributetype ( 1.3.6.1.4.1.7914.1.2.1.6 NAME 'mailForward'
DESC 'Address(es) to forward all incoming messages to.'
EQUALITY caseIgnoreIA5Match
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )
attributetype ( 1.3.6.1.4.1.7914.1.2.1.7 NAME 'mailClearpw'
DESC 'clear password of the user on the mailsystem'
EQUALITY caseExactMatch
SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{32}
SINGLE-VALUE )
attributetype ( 1.3.6.1.4.1.7914.1.2.1.9 NAME 'mailReplyText'
DESC 'A reply text for every incoming message'
EQUALITY caseIgnoreMatch
SUBSTR caseIgnoreSubstringsMatch
SYNTAX 1.3.6.1.4.1.1466.115.121.1.44{4096}
SINGLE-VALUE )
attributetype ( 1.3.6.1.4.1.7914.1.2.1.11 NAME 'userStatus'
DESC 'The status of a user account'
EQUALITY integerMatch
ORDERING integerOrderingMatch
SYNTAX 1.3.6.1.4.1.1466.115.121.1.27
SINGLE-VALUE )
attributetype ( 1.3.6.1.4.1.7914.1.2.1.12 NAME 'userRegisterDate'
DESC 'timestamp of user registration'
SYNTAX 1.3.6.1.4.1.1466.115.121.1.27
SINGLE-VALUE )
attributetype ( 1.3.6.1.4.1.7914.1.2.1.13 NAME 'userExpireDate'
DESC 'timestamp of user mailbox expiration'
SYNTAX 1.3.6.1.4.1.1466.115.121.1.27
SINGLE-VALUE )
# Object Class Definitions
objectclass ( 1.3.6.1.4.1.7914.1.2.2.1 NAME 'mailUser'
DESC 'Mail-LDAP User' SUP top STRUCTURAL
MUST ( mail $ cn $ uid )
MAY ( userPassword $ uidNumber $ gidNumber $ homeDirectory $ mailMessageStore $
mailHost $ mailForward $ mailQuota $ displayName $ mailReplyText $
userStatus $ userRegisterDate $ userExpireDate ) )
3、postfix.schema
# postfix-ldap directory schema v0.1
# Created by: netkiller <netkiller@9812.net>
# Created: 2004-4-12
# Note: The attribute and objectclass OIDs are valid
# Attribute Type Definitions
# Postfix Style
#attributetype ( 1.3.6.1.4.1.7006.1.2.1.1 NAME 'uidnumber'
DESC 'UID of the user on the mailsystem'
EQUALITY integerMatch
SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE )
#attributetype ( 1.3.6.1.4.1.7006.1.2.1.2 NAME 'gidnumber'
DESC 'GID of the user on the mailsystem'
EQUALITY integerMatch
SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE )
attributetype ( 1.3.6.1.4.1.12461.1.1.5 NAME 'mailbox'
DESC 'The absolute path to the mailbox for a mail account in a non-default location'
EQUALITY caseExactIA5Match
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE )
attributetype ( 1.3.6.1.4.1.12461.1.1.6 NAME 'quota'
DESC 'A string that represents the quota on a mailbox'
EQUALITY caseExactIA5Match
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE )
attributetype ( 1.3.6.1.4.1.12461.1.1.8 NAME 'maildrop'
DESC 'RFC822 Mailbox - mail alias'
EQUALITY caseIgnoreIA5Match
SUBSTR caseIgnoreIA5SubstringsMatch
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{256} )
attributetype ( 1.3.6.1.4.1.12461.1.1.7 NAME 'clearPassword'
DESC 'A separate text that stores the mail account password in clear text'
EQUALITY octetStringMatch
SYNTAX 1.3.6.1.4.1.1466.115.121.1.40{128})
attributetype ( 1.3.6.1.4.1.12461.1.1.9 NAME 'mailsource'
DESC 'Message source'
EQUALITY caseIgnoreIA5Match
SUBSTR caseIgnoreIA5SubstringsMatch
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )
# Qmail Style
attributetype ( 1.3.6.1.4.1.7006.1.2.1.1 NAME 'qmailUID'
DESC 'UID of the user on the mailsystem'
EQUALITY integerMatch
SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE )
attributetype ( 1.3.6.1.4.1.7006.1.2.1.2 NAME 'qmailGID'
DESC 'GID of the user on the mailsystem'
EQUALITY integerMatch
SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE )
attributetype ( 1.3.6.1.4.1.7006.1.2.1.3 NAME 'mailMessageStore'
DESC 'Path to the maildir/mbox on the mail system'
EQUALITY caseExactIA5Match
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE )
attributetype ( 1.3.6.1.4.1.7006.1.2.1.4 NAME 'mailAlternateAddress'
DESC 'Secondary (alias) mailaddresses for the same user'
EQUALITY caseIgnoreIA5Match
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )
attributetype ( 1.3.6.1.4.1.7006.1.2.1.5 NAME 'mailQuota'
DESC 'The amount of space the user can use until all further messages get bounced.'
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE )
attributetype ( 1.3.6.1.4.1.7006.1.2.1.6 NAME 'mailHost'
DESC 'On which qmail server the messagestore of this user is located.'
EQUALITY caseIgnoreIA5Match
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE )
attributetype ( 1.3.6.1.4.1.7006.1.2.1.7 NAME 'mailForwardingAddress'
DESC 'Address(es) to forward all incoming messages to.'
EQUALITY caseIgnoreIA5Match
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )
attributetype ( 1.3.6.1.4.1.7006.1.2.1.8 NAME 'deliveryProgramPath'
DESC 'Program to execute for all incoming mails.'
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE )
attributetype ( 1.3.6.1.4.1.7006.1.2.1.9 NAME 'qmailDotMode'
DESC 'Interpretation of .qmail files: both, dotonly, ldaponly, ldapwithprog, none'
EQUALITY caseIgnoreIA5Match
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE )
attributetype ( 1.3.6.1.4.1.7006.1.2.1.10 NAME 'deliveryMode'
DESC 'multi field entries of: normal, forwardonly, nombox, localdelivery, reply, echo'
EQUALITY caseIgnoreIA5Match
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )
attributetype ( 1.3.6.1.4.1.7006.1.2.1.11 NAME 'mailReplyText'
DESC 'A reply text for every incoming message'
SUBSTR caseIgnoreSubstringsMatch
SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{1024} SINGLE-VALUE )
attributetype ( 1.3.6.1.4.1.7006.1.2.1.12 NAME 'accountStatus'
DESC 'The status of a user account: active, nopop, disabled'
EQUALITY caseIgnoreIA5Match
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE )
# Postfix Virtual Domain
attributetype ( 1.3.6.1.4.1.12461.1.1.4 NAME 'vd'
DESC 'A virtual domain managed by Jamm'
EQUALITY caseIgnoreIA5Match
SUBSTR caseIgnoreIA5SubstringsMatch
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )
attributetype ( 1.3.6.1.4.1.12461.1.1.1 NAME 'transport'
DESC 'A string directing postfix which transport to use'
EQUALITY caseExactIA5Match
SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{20} SINGLE-VALUE )
# Object Class Definitions
objectclass ( 1.3.6.1.4.1.12461.1.2.1 NAME 'postfixAccount'
DESC 'Postfix-LDAP User' SUP top AUXILIARY
MUST ( mail $ uid )
MAY ( mailbox $ quota $ maildrop $ clearPassword $
mailMessageStore $ homeDirectory $ userPassword $
mailAlternateAddress $ uidnumber $ gidnumber $ mailQuota $
mailHost $ mailForwardingAddress $ mailReplyText $
accountStatus ) )
objectclass ( 1.3.6.1.4.1.12461.1.2.2 NAME 'postfixAliases'
SUP top STRUCTURAL
DESC 'Mail aliasing/forwarding entry'
MUST ( mail $ uid )
MAY ( maildrop $ description $ mailForwardingAddress $ accountStatus ) )
objectclass ( 1.3.6.1.4.1.12461.1.2.3 NAME 'postfixVirtualDomain'
SUP top STRUCTURAL
DESC 'Virtual Domain entry to be used with postfix transport maps'
MUST ( vd $ transport )
MAY ( o $ description $ accountStatus ) )
# Qmail Object Class Definitions
objectclass ( 1.3.6.1.4.1.7006.1.2.2.1 NAME 'qmailUser'
DESC 'QMail-LDAP User' SUP top AUXILIARY
MUST ( mail $ uid )
MAY ( mailMessageStore $ homeDirectory $ userPassword $
mailAlternateAddress $ qmailUID $ qmailGID $ mailQuota $
mailHost $ mailForwardingAddress $ deliveryProgramPath $
qmailDotMode $ deliveryMode $ mailReplyText $
accountStatus ) )

