Skip to content

download emails from attached mailbox microsoft exchange

Initial data

Source URL: https://webmail.domain.com/owa/ AD credentials : domain\administrator Account [email protected] has permissions on the [email protected] mailbox

Tested on MS Exchange: 2013

Install offlineimap

apt install offlineimap

offlineimap config

$ cat second_domain.com.offlineimap.conf

[general]
accounts = account_sync

[Account account_sync]
localrepository = local_maildir
remoterepository = imap
# Important for Cyrillic folder names
utf8foldernames = yes

[Repository local_maildir]
type = Maildir
localfolders = /var/mail/domain.com/second
sep=.
# for MailDir structure compatibillity
nametrans = lambda folder: folder[1:]

[Repository imap]
maxconnections = 3
type = IMAP
ssl = no
createfolders = False
# davmail host:port
remotehost = localhost
remoteport = 1143
# Symbols \\ - it's not mistake
remoteuser = domain\\administrator\s[email protected]
remotepass = MYPASSWORD
# critical option for copy attached mailbox
folderfilter= lambda folder: (not re.search('^/users/.*$|^Ошибки синхронизаци|^Sync Issues',folder)) & (folder not in 
['Calendar','Working Set'])
# for MailDir structure compatibillity
nametrans = lambda folder: '.'+folder

davmail config

$ grep '.url\|.imap\|.mode' ~/.davmail.properties 

davmail.imapAutoExpunge=true
davmail.ssl.nosecureimap=false
davmail.mode=EWS
davmail.imapPort=1143
davmail.url=https://webmail.domain.com/EWS/Exchange.asmx
davmail.imapAlwaysApproxMsgSize=false
davmail.imapIdleDelay=

Checking disabled folders

# run
offlineimap -c second_domain.com.offlineimap.conf --info

...
Folderlist:
 /users/[email protected]/ (disabled)
...
 Sync Issues (disabled)
 Sync Issues/Conflicts (disabled)
 Sync Issues/Local Failures (disabled)
 Sync Issues/Server Failures (disabled)
...

https://fossies.org/linux/offlineimap/offlineimap.conf https://linux.die.net/man/1/offlineimap