this is obsolete doc -- see http://doc.nethence.com/ instead
Setting up DavMail as standalone server (MS Exchange proxy) with SSL enabled
http://pbraun.nethence.com/unix/mail/davmail.html
http://pbraun.nethence.com/unix/sysutils_linux/systemd.html
Introduction
I only need DavMail to access Exchange calendar service from Thunderbird/Lightning. Everything else works directly:
SMTP & IMAP --> Exchange directly
LDAP addressbook --> AD directly on port 3268 (need to switch to LDAPS 3269)
Requirements
Make sure Java is installed (using java-1.8.0-openjdk),
yum -y install java
you will probably need X11 forwarding too (enabled by default on CentOS),
yum -y install xauth
Disable listen on port 25 to free that port,
cd /etc/postfix/
cp master.cf master.cf.dist
vi master.cf
#smtp inet n - n - - smtpd
service postfix restart
If you need SSL, upload you java keystore or your apache pem to the server.
Installation
Fetch the [latest tarball](http://sourceforge.net/projects/davmail/files/davmail/) and extract,
tar xzf davmail-linux-x86_64-4.7.1-2416.tgz
mv davmail-linux-x86_64-4.7.1-2416/ /usr/local/
mv svrkeystore.jks /usr/local/davmail-linux-x86_64-4.7.1-2416/
ls -l /usr/local/davmail/svrkeystore.jks
cd /usr/local/
ln -s davmail-linux-x86_64-4.7.1-2416 davmail
Configuration
Test that the tool is working normally in graphical mode and proceed with its setup,
/usr/local/davmail/davmail.sh ==> DavMail Gateway Settings
Main tab / OWA URL: https://mailexchange-server.domain.tld/owa/
Main tab / Caldav HTTP 443 (keep ssl enabled)
Network tab / Allow Remote Connections
Encryption tab / store type: JKS
Encryption tab / keystore: /usr/local/davmail/svrkeystore.jks
Encryption tab / keystore pass: ...
Encryption tab / key pass: ...
==> save do some CalDav testing with Thunderbird/Lightning.
Once everything works fine, save the configuration and enable server mode,
cd ~/
ls -l .davmail.properties
mv .davmail.properties /usr/local/davmail/davmail.properties.gui
cd /usr/local/davmail/
sed 's/davmail.server=false/davmail.server=true/' davmail.properties.gui > davmail.properties.server-mode
diff davmail.properties.gui davmail.properties.server-mode
grep -i url davmail.properties.server-mode
grep Port davmail.properties.server-mode
Ready to go
You can now run the tool as a deaemon,
cd /usr/local/davmail/
ps ax | grep davmail
nohup ./davmail.sh davmail.properties.server-mode > davmail.more.log 2> davmail.more-err.log &
Check that it's now listeing on the desired ports,
netstat -an --inet --inet6 | grep 443
Start/stop scripts,
mkdir -p ~/bin/
cd ~/bin/
vi start_davmail.ksh
#!/bin/ksh
print Starting DavMail:
cd /usr/local/davmail/
nohup ./davmail.sh davmail.properties.server-mode > davmail.more.log 2> davmail.more-err.log &
ps aux | grep davmail | grep -v grep
vi stop_davmail.ksh
#!/bin/ksh
print Shuting down DavMail... \\c
pid=`ps ax | grep davmail | grep -v grep | awk '{print $1}'`
[[ -z $pid ]] && print no pid found && exit 1
kill $pid && print Done
sleep 1
ps aux | grep davmail | grep -v grep
vi status_davmail.ksh
#!/bin/ksh
ps aux | grep davmail | grep -v grep
chmod +x start_davmail.ksh status_davmail.ksh stop_davmail.ksh
Thunderbird configuration
with SSL enabled on the server
For Calendar (lightning),
click on the little calendar icon on the top right corner
File > New > Calendar
on the network
caldav
location: https://davmail.examplessl.net/users/long-email@addomain.tld/calendar
offline ok
name: COMPANY
Email: select the mail account
Note. the https address needs to point to the SSL enabled FQDN, otherwise it won't work.
Wait for a second and your corporate calendar will show up. Eventually uncheck your persoan Calendar to let the corporate one enabled only.
Additional notes
To LDAP search only users,
Advanced / (&(objectclass=user)(msexchuserAccountcontrol=0))
References
DavMail Setup as a standalone server: http://davmail.sourceforge.net/serversetup.html
DavMail : la passerelle Exchange: https://doc.ubuntu-fr.org/davmail
https://www.arclab.com/en/kb/email/list-of-smtp-and-imap-servers-mailserver-list.html
https://www.arclab.com/en/kb/email/list-of-smtp-and-pop3-servers-mailserver-list.html
https://www.siteground.com/tutorials/email/pop3-imap-smtp-ports.htm
Understanding LDAP Search Filters: https://fr.websense.com/content/support/library/web/hosted/dsc_admin/query_filter.aspx
http://social.technet.microsoft.com/wiki/contents/articles/5392.active-directory-ldap-syntax-filters.aspx
https://technet.microsoft.com/fr-fr/library/aa996205(v=exchg.65).aspx
Integrate Thunderbird with Active Directory: https://www.howtoforge.com/thunderbird_active_directory