A set of command line utilities to interact with an exchange server, powered by the excellent exchangelib
Requirements:
- bash
- Python 3
-
Clone the repo and create a virtualenv importing the
requirements.txt
file.git clone [email protected]:flerro/ews-cli-tools.git ews-cli cd ews-cli python3 -m venv ./venv source ./venv/bin/activate pip install -r requirements.txt
On Ubuntu derivatives
python3-dev
package is required to compile all dependecies. -
Create the
conf.yml
configuration file, please refer toconf.template.yml
for an example)account: email: [email protected] domain: DOMAIN user: USR1234 password: PASSWORD ews: server: mail.domain.com # OWA server chunk: 25 # Batch size for each download request backup: months: 9 # Backup messages until n months since today delete: False # Delete message after local download?
-
(optionally) Add the
bin
folder to pathexport PATH=$PATH:
pwd/bin
The backup.sh
script will download messages from inbox
and sent
folders and store them locally.
Downloaded messages can be optionally removed from server.
Each message is saved to a self-contained .eml
file, named after message date-time and subject.
The backup folder is organized by folder, year and month. Messages in inbox folder are also organized by sender.
account
├── inbox
│ ├── 2018
│ │ ├── 02
│ │ │ ├── [email protected]
│ │ │ │ ├── 2018-02-01_0722___subject1.eml
│ │ │ │ └── 2018-02-10_1137___subject2.eml
...
│
└── sent
├── 2018
│ ├── 03
│ │ ├── 2018-03-01_0722___subject1.eml
│ │ └── 2018-03-10_1137___subject2.eml
...
└── 2019
├── 03
│ ├── 2019-03-07_0722___subject1.eml
│ └── 2019-03-11_1137___subject2.eml
...
This directory structure enable e-mail search by standard unix tools. Use:
find . -type d ...
to locate a sender,find . -name ...
for a specific subjectgrep -R ...
to search in message content.
Please note that sub-folders under inbox
and sent
are currently not processed
Use the text_extract.sh
script to extract text from a multipart e-mail message stored in eml
format.
Any email client on Linux (e.g. Kmail, Evolution) is able to read the eml
format.
xdg-open filename.eml
Use mpack
to extract attachments from the command line.
$ sudo apt-get install mpack
$ munpack email.eml
tempdesc.txt: File exists
image001.jpg.3 (image/jpeg)
If you have Outlook PST or OST archive laying around, you can extract messages to eml
format via readpst
.
$ sudo apt install pst-utils
$ readpst -o mailbox -e archive.pst
Opening PST file and indexes...
Processing Folder "Posta eliminata"
Processing Folder "Posta in arrivo"
Processing Folder "Posta in uscita"
"Posta eliminata" - 0 items done, 2 items skipped.
...