Ubuntu 5.10 + Open-XChange 0.8.0-6 + Postfix How-To

by Diego Fantoma (diego_AT_fantoma.it - http://www.fantoma.it), march 2006



Installation

Become super-user if you aren't:

su -
apt-get install postfix

On conf question set Internet site as the General Profile: Internet site and leave the default Mail name: localhost.localdomain

Preliminary configuration

mv /etc/postfix/main.cf /etc/postfix/main.cf.ORG
cat /etc/postfix/main.cf.ORG |\
sed "s/^mydestination.*$/mydestination=$MAILDOMAIN, mail\.$MAILDOMAIN, localhost\.localdomain, localhost/" |\
sed "s/^myhostname.*$/myhostname=mail\.$MAILDOMAIN/" |\
sed "s/^myorigin.*$/myorigin=$MAILDOMAIN/" > /etc/postfix/main.cf

postfix stop;postfix start

Testing preliminary configuration

Testing Postfix for passwd user database:

TESTUSER=$(cat /etc/passwd|grep ':x:1000:1000:'|awk -F: '{print $1}' ); export TESTUSER
echo this is a message|sendmail $TESTUSER@$MAILDOMAIN
cat /var/mail/$TESTUSER

You must see the message you sent.
If not, check postfix configuration.

Try sending a mail to an external mail server, eg:

echo this is a message for external user|sendmail myrecipient@external.domain

And check if you receive the message. Warning: It could be that your sending domain is not registered so that your destination mail server could reject your message!
In this case try to watch in the /var/log/syslog if the message is rejected.

LDAP Configuration

Setting up postfix for ldap OX users database.


apt-get install postfix-ldap

mv /etc/postfix/main.cf /etc/postfix/main.cf.PRE
cat /etc/postfix/main.cf.PRE |\
sed "s/^mydestination/#mydestination/" > /etc/postfix/main.cf

echo >> /etc/postfix/main.cf
echo '# -- LDAP MAPS --' >> /etc/postfix/main.cf
echo >> /etc/postfix/main.cf
echo 'mydestination= ldap:/etc/postfix/ldap_domain.cf' >> /etc/postfix/main.cf
echo 'local_recipient_maps = ldap:/etc/postfix/ldap_mbox.cf' >> /etc/postfix/main.cf
echo 'home_mailbox = /Maildir' >> /etc/postfix/main.cf
echo 'virtual_transport=virtual' >> /etc/postfix/main.cf
echo 'local_transport = virtual' >> /etc/postfix/main.cf
echo >> /etc/postfix/main.cf
echo 'virtual_recipient_maps = ldap:/etc/postfix/ldap_mbox.cf' >> /etc/postfix/main.cf
echo 'virtual_alias_maps = ldap:/etc/postfix/ldap_alias.cf' >> /etc/postfix/main.cf
echo 'virtual_mailbox_maps = ldap:/etc/postfix/ldap_dir.cf' >> /etc/postfix/main.cf
echo 'virtual_uid_maps = ldap:/etc/postfix/ldap_uid.cf' >> /etc/postfix/main.cf
echo 'virtual_gid_maps = ldap:/etc/postfix/ldap_gid.cf' >> /etc/postfix/main.cf
echo 'virtual_mailbox_domains= ldap:/etc/postfix/ldap_domain.cf' >> /etc/postfix/main.cf
echo 'virtual_mailbox_base = /' >> /etc/postfix/main.cf
echo 'virtual_minimum_uid = 500' >> /etc/postfix/main.cf
echo 'virtual_mailbox_limit = 0' >> /etc/postfix/main.cf

echo "server_host = localhost" > /etc/postfix/ldap_common.cf
echo "server_port = 389" >> /etc/postfix/ldap_common.cf
echo "bind = yes" >> /etc/postfix/ldap_common.cf
echo "version = 3" >> /etc/postfix/ldap_common.cf
echo "bind_dn = cn=Manager,$DCDOMAIN" >> /etc/postfix/ldap_common.cf
echo "bind_pw = $PASSWORD" >> /etc/postfix/ldap_common.cf
echo "search_base = ou=Users,ou=OxObjects,$DCDOMAIN" >> /etc/postfix/ldap_common.cf

cp /etc/postfix/ldap_common.cf /etc/postfix/ldap_domain.cf
cp /etc/postfix/ldap_common.cf /etc/postfix/ldap_mbox.cf
cp /etc/postfix/ldap_common.cf /etc/postfix/ldap_alias.cf
cp /etc/postfix/ldap_common.cf /etc/postfix/ldap_dir.cf
cp /etc/postfix/ldap_common.cf /etc/postfix/ldap_uid.cf
cp /etc/postfix/ldap_common.cf /etc/postfix/ldap_gid.cf

echo "query_filter = (mailDomain=%s)" >> /etc/postfix/ldap_domain.cf
echo "result_attribute = mailDomain" >> /etc/postfix/ldap_domain.cf

echo "query_filter = (&(uid=%u)(mailEnabled=OK))" >> /etc/postfix/ldap_mbox.cf
echo "result_attribute = mail" >> /etc/postfix/ldap_mbox.cf

echo "query_filter = (alias=%s)" >> /etc/postfix/ldap_alias.cf
echo "result_attribute = mail" >> /etc/postfix/ldap_alias.cf

echo "query_filter = (&(uid=%u)(mailEnabled=OK))" >> /etc/postfix/ldap_dir.cf
echo "result_attribute = homeDirectory" >> /etc/postfix/ldap_dir.cf
echo "result_filter = %s/Maildir/" >> /etc/postfix/ldap_dir.cf

echo "query_filter = (&(uid=%u)(mailEnabled=OK))" >> /etc/postfix/ldap_uid.cf
echo "result_attribute = uidNumber" >> /etc/postfix/ldap_uid.cf

echo "query_filter = (&(uid=%u)(mailEnabled=OK))" >> /etc/postfix/ldap_gid.cf
echo "result_attribute = gidNumber" >> /etc/postfix/ldap_gid.cf

chgrp 500 /home
chmod 775 /home

postfix reload

Now try to sending a message to a Open-XChange user, e.g. the fantoma@ld2005.linux.trieste.it created in the previous How-To:

echo this is a message for OX user|sendmail fantoma@ld2005.linux.trieste.it

The directory is automagically created for the user and a message has to appear in the ~/Maildir/new folder:

ls /home/fantoma/Maildir/new

If you try to login into the Open-XChange you cannot find any message because on the server isn't [yet] installed any IMAP server!!