当前位置:操作系统 > Unix/Linux >>

Openldap+Postfix+courier-imap+FreeBSD实现邮件服务

Openldap+Postfix+courier-imap+FreeBSD实现邮件服务(v1.1)

  注:本文参照网上http://annapolislinux.org/docs/plc/postfix-courier-howto.txt这篇文章,在FreeBSD系统上进行实现,该文章可自由发布/修改,但在发布时请注明出处,谢谢合作。

  name:zhangluoer

  QQ:36752833

  E-mail:zhangluoer@eyou.com

  ##########

  #

  install Openldap

  ##########

  A》Openldap install

  #cd /usr/ports/net/openldap21-server

  #make install

  #make clean

  经过上面的动作,FreeBSD已经将openldap安装在系统上。就这么简单比在linux下安装软件要容易的多了。

  B》Configure Openldap

  1> Edit /usr/local/etc/openldap/ldap.conf

  #used by (server) ldap client programs

  #to connect to the ldap server

  BASE dc=mycoll, dc=edu

  HOST localhost

  pam_crypt local

  2>Edit /usr/local/etc/openldap/slapd.conf

  这个配置文件不应该让同组和其它人看到,顾应设属性为 0700

  include /etc/usr/local/openldap/shcema/core.schema

  include /etc/usr/local/openldap/shcema/cosine.schema

  include /etc/usr/local/openldap/shcema/nis.schema

  include /etc/usr/local/openldap/shcema/inetorgperson.schema

  # courier imap

  include /etc/usr/local/openldap/shcema/authldap.schema

  # postfix qmail

  include /etc/usr/local/openldap/shcema/qmail.schema

  注:authldap.shcema和qmail.schema系统中自带的是没有这两个文件的,所以可以到网上去下载这两个文件,但要注意下载后文件的格式如果不正确(一小点格式问题)就会在配置时不通过。特别是从windows下载后在FreeBSD中进行使用。

  pidfile /var/run/openldap/slapd.pid

  argsfile /var/run/openldap/slapd.args

  moduleload back_ldap.la

  #prevents user froom looking at passwords

  access to attr=userpassword,clearpassword

  by anonymous auth

  by self write

  by dn="cn=admin,dc=365,dc=net" write

  by dn="cn=courier,dc=365,dc=net" read

  by * none

  #files need access to this

  access to attr=accountstatus

  by dn="cn=admin,dc=365,dc=net" read

  by dn="cn=courier,dc=365,dc=net" read

  access to *

  by dn="cn=admin,dc=365,dc=net" write

  by users read

  by self write

  by * none

  注:上面的格式同样重要,所有的“by……”语句前必须有一个tab制表位,我就是当初没有加上这个东西,让我找了半天毛病。

  databate bdb

  suffix "dc=365,dc=net"

  rootdn "cn=admin,dc=365,dc=net"

  rootpw secret

  directory /usr/db/openldap-data

  replogfile /usr/db/replication.log

  loglevel 0

  index cn,sn,mail,uid eq

  index objectclass eq

  3>Run Openldap

  # cd /usr/local/libexec

  # ./slapd

  4>Add your Openldap data

  Data in an LDAP database goes in Top down.You have to define the top level organization first before moving on. (这是一个技巧,就是当添加内容的时候,不要在文件的末尾添加,最好在文件的开头添加,这样的好处是不会碰上记录已经存在的问题。自己做时比较一下就会明白。)

  # vi 365.net.ldif

  dn:dc=365,dc=net

  objectclass:dcobjectclass

  objectclassrganization

  dc=365

  o:365

  description:Top level of directory

  dn:cn=admin,dc=365,dc=net

  jectclassrganizationalRole

  cn:admin

  scriptionirectory Manager

  scription:top level of the directory

  dnu=people,dc=365,dc=net

  objectclass:top

  objectclassrganizationunit

  ou:people

  descritpion:people within 365.net (people information)

  dnu=mailaccounts,dc=365,dc=net

  objectclass:top

  objectclassrganizationalunit

  ou:mailaccounts

  description:people with mallaccounts at 365.net

  dn:cn=courier,dc=365,dc=net

  objectclass:person

  cn:courier

  sn:courier

  userpassword:yoursecret

  description:courier daemons

  dn:cn=postfix,dc=365,dc=net

  objectclass:person

  cn:postfix

  :postfix

  erpassword:yoursecret

  scription:postfix daemons

  注:上面是openldap中的基本结构,根目录为365.net,目录中有三个用户:admin、postfix、courier;两个容器: people、mailaccounts(其中people中存放个人资料,mailaccounts中存放用户的邮箱信息。)

  365.net admin 、postfix 、courier

  |

  |___people zhxh、………还有更多的用户信息(比如:电话,邮编等)

  |

  |___ mailaccounts zhxh、………其它更多的用户邮箱信息

  #ldapadd -W -D "cn=admin,dc=365,dc=net" -f 365.net.ldif -x

  #vi first.ldif

  dn:uid=zhxh,ou=mailaccounts,dc=365,dc=net

  uid:zhxh

  cn:zhxh

  sn:zhxh

  mail:zhxh@365.net

  uidnumber:1001

  gidnumber:1001

  mailhost:mail.365.net

  homedirectory:/home/zhxh/

  mailmessagestore:/home/zhxh/maildir/

  mailquota:200000000s,20000c

  mailbox:zhxh/maildir/

  objectclass:qmailuser

  objectclass:couriermailaccount

  objectclass:person

  #ldapadd -W -D "cn=admin,dc=365,dc=net"

  ###########

  #install postfix

  ###########

  A》postfix install

  # cd /usr/ports/mail/postfix-current

  # make install

  # make clean

  B》configure postfix

  # vi /usr/local/etc/postfix/main.cf

  biff=no

  smtp_banner=$myhostname Esmtp No NCE

  debug_peer_level=2

  delay_warning_time=4

  command_directory=/usr/local/sbin

  config_directory=/usr/local/etc/postfix

  daemon_directory=/usr/local/libexec/postfix

  mail_owner=postfix

  myhostname=ldap.365.net

  mydomain=365.net

  myorigin=$mydomain

  mydestion=$myhostname,$mydomain,localhost.$mydomain

  mynetworks=127.0.0.0/8

  masquerade_domain=$mydomain

  masquerade_exceptions=root,mailer_daemon,postmaster

  local_transport=virtual

  local_recipient_maps=$virtual_mailbox_maps

  virtual_mailbox_maps=ldap:ldapsource

  recipient_limit=1

  message_size_limit=10280000

  mailbox_size_limit=20480000

  virtual_uid_maps=ldap:ldapuid

  virtual_gid_maps=static:1001

  virtual_recipient_size_limit=200000000s,20000c

  virtual_minimum_uid=500

  virtual_mailbox_base=/home/

  virtual_result_attribute=mailbox

  virtual_mailbox_maps=ldap:ldapsource

  virtual_maildir_extended=yes

  ldapuid_timeout=10

  ldapuid_server_host=ldap.365.net

  ldapuid_server_port=389

  ldapuid_search_base=ou=mailaccounts,dc=365,dc=net

  ldapuid_domain=365.net

  ldapuid_query_filter=(&(mail=%s)(accountstatus=active))

  ldapuid_result_attribute=uidnumber

  ldapuid_bind=yes

  ld
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,