Настройка Postfix для Работы с LDAP

Postfix – это Mail Transfer Agent (MTA), т.е. агент передачи почты.

Postfix является прекрасной альтернативой Sendmail. Он работает быстрее, проще в настройке, обладает большей безопасностью и совместим с Sendmail.

Архитектура Postfix – модульная и выполнена в стиле UNIX, т.е. для своей работы Postfix использует небольшие утилиты.

Postfix не является агентом доставки электронной почты.

В данной статье описан процесс настройка Postfix для работы с LDAP.

Создание пользователя vmail

# mkdir /var/vmail/
# useradd -u 400 vmail

Создание каталога для хранения почты

# chown -R vmail:vmail /var/vmail/

/etc/postfix/main.cf

queue_directory = /var/spool/postfix
command_directory = /usr/sbin
daemon_directory = /usr/libexec/postfix
mail_owner = postfix
myhostname = server1.lystor.org.ua
mydomain = lystor.org.ua
myorigin = $myhostname
inet_interfaces = localhost, 192.168.0.254
mydestination = $myhostname, localhost.$mydomain, localhost
unknown_local_recipient_reject_code = 550
mynetworks_style = host
mynetworks=$config_directory/mynetworks
relay_domains = $mydestination, $transport_maps
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
home_mailbox = Maildir/
debug_peer_level = 2
debugger_command =
         PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin
         xxgdb $daemon_directory/$process_name $process_id & sleep 5
sendmail_path = /usr/sbin/sendmail.postfix
newaliases_path = /usr/bin/newaliases.postfix
mailq_path = /usr/bin/mailq.postfix
setgid_group = postdrop
html_directory = no
manpage_directory = /usr/share/man
sample_directory = /usr/share/doc/postfix-2.3.3/samples
readme_directory = /usr/share/doc/postfix-2.3.3/README_FILES
smtpd_helo_required = yes
smtpd_recipient_restrictions =
   permit_mynetworks
   reject_unauth_destination
   reject_non_fqdn_recipient
   reject_unlisted_recipient
smtpd_sender_restrictions =
   reject_non_fqdn_sender
smtpd_data_restrictions = reject_unauth_pipelining
message_size_limit = 50000000
mailbox_size_limit = 1000000000
virtual_alias_maps       = ldap:/etc/postfix/ldap_virtual_alias_maps.cf
virtual_mailbox_domains  = ldap:/etc/postfix/ldap_virtual_mailbox_domains.cf
virtual_mailbox_maps     = ldap:/etc/postfix/ldap_virtual_mailbox_maps.cf
transport_maps           = ldap:/etc/postfix/ldap_transport_maps.cf
local_transport = virtual
virtual_gid_maps = static:400
virtual_mailbox_base = /var/vmail
virtual_mailbox_limit = 1000000000
virtual_minimum_uid = 400
virtual_uid_maps = static:400

/etc/postfix/ldap_virtual_alias_maps.cf

server_host = ldap.lystor.org.ua
server_port = 389
bind = yes
bind_dn = uid=postfix,ou=postfix,ou=Service,dc=lystor,dc=org,dc=ua
bind_pw = SUPER_PASSWORD
search_base = ou=virtual_alias_maps,ou=postfix,ou=Service,dc=lystor,dc=org,dc=ua
query_filter = (&(objectClass=mailRecipient)(mailAlternateAddress=%s))
result_attribute = mail

/etc/postfix/ldap_virtual_mailbox_domains.cf

server_host = ldap.lystor.org.ua
server_port = 389
bind = yes
bind_dn = uid=postfix,ou=postfix,ou=Service,dc=lystor,dc=org,dc=ua
bind_pw = SUPER_PASSWORD
search_base = ou=virtual_mailbox_domains,ou=postfix,ou=Service,dc=lystor,dc=org,dc=ua
query_filter = (&(objectClass=mailRecipient)(mailHost=%s))
result_attribute = mailHost

/etc/postfix/ldap_virtual_mailbox_maps.cf

server_host = ldap.lystor.org.ua
server_port = 389
bind = yes
bind_dn = uid=postfix,ou=postfix,ou=Service,dc=lystor,dc=org,dc=ua
bind_pw = SUPER_PASSWORD
search_base = ou=People,dc=lystor,dc=org,dc=ua
query_filter = (&(objectClass=mailRecipient)(|(mail=%s)(mailAlternateAddress=%s)))
result_attribute = mailMessageStore

/etc/postfix/ldap_transport_maps.cf

server_host = ldap.lystor.org.ua
server_port = 389
bind = yes
bind_dn = uid=postfix,ou=postfix,ou=Service,dc=lystor,dc=org,dc=ua
bind_pw = SUPER_PASSWORD
search_base = ou=transport_maps,ou=postfix,ou=Service,dc=lystor,dc=org,dc=ua
query_filter = (&(objectClass=mailRecipient)(mail=%s))
result_attribute = mailForwardingAddress

Статьи по Теме

Категории
Поиск