A Python wrapper for the Zimbra Web Interface
Project description
Python Zimbra Web
branch | status |
---|---|
main | |
develop |
Usage
For the entire documentation please see https://cirosec-studis.github.io/python-zimbra-web.
The documentation for the develop branch can be found here: https://cirosec-studis.github.io/python-zimbra-web/develop/
You can use ZimbraUser
to send E-mails. You can send multiple E-mails within a single session.
from zimbraweb import ZimbraUser
user = ZimbraUser("https://myzimbra.server")
user.login("s000000", "hunter2")
user.send_mail(to="receiver@example.com", subject="subject", body="body", cc="cc@example.com")
user.logout()
Sending EMLs
Please note the Limitations when trying to parse EML.
from zimbraweb import ZimbraUser
user = ZimbraUser("https://myzimbra.server")
user.login("s000000", "hunter2")
emlstr = open("myemlfile.eml").read()
user.send_eml(emlstr)
Sending raw WebkitPayloads
If you don't want to rely on us to generate the payload, you can generate a payload yourself and send it using
from zimbraweb import ZimbraUser
user = ZimbraUser("https://myzimbra.server")
user.login("s000000", "hunter2")
# you could also generate the payload yourself or use our library
raw_payload, boundary = user.generate_webkit_payload(to="to@example.com", subject="hello world!", body="this is a raw payload.")
# then send the raw_payload bytes
user.send_raw_payload(raw_payload, boundary)
user.logout()
Attachments
You can generate attachments using the WebkitAttachment
class:
from zimbraweb import ZimbraUser, WebkitAttachment
user = ZimbraUser("https://myzimbra.server")
user.login("s000000", "hunter2")
attachments = []
with open("myfile.jpg", "rb") as f:
attachments.append(WebkitAttachment(content=f.read(), filename="attachment.jpg"))
user.send_mail(to="receiver@example.com", subject="subject", body="body", attachments=attachments)
user.logout()
Known Limitations
- Emoji is not supported, even though other UTF-8 characters are. See Issue #3
- This package is made with German UIs in mind. If your UI is in a different language, feel free to fork and adjust the language-specific strings as needed. Issue #43
- The EML parsing can strictly only parse plaintext emails, optionally with attachments. Any emails with a Content-Type other than
text/plain
ormultipart/mixed
will be rejected. This is because the zimbra web interface does not allow HTML emails. Parsingmultipart/mixed
will only succeed if there is exactly onetext/plain
part and, optionally, attachments with theContent-Disposition: attachment
header. If there are anymultipart/alternative
parts, the parsing will fail because we cannot deliver them to the Zimbra web interface.
Install
pip install zimbraweb
Contributing
- Best practice is to develop in a python3.8 virtual env:
python3.8 -m venv env
,source env/bin/activate
(Unix) orenv\Scripts\activate.ps1
(Windows) - Install dev-requirements
pip install -r requirements_dev.txt
- When working on a new feature, checkout to
git branch -b feature_myfeaturename
. We are using this branching model - Before committing, check
mypy src
returns no failures.flake8 src tests
returns no problems.pytest
has no unexpected failed tests.- Optionoally, test with
tox
. Might take a few minutes so maybe only run before push.
Development Install
$ git clone https://github.com/cirosec-studis/python-zimbra-web/
$ cd python-zimbra-web
$ pip install -e .
This installs the package with symlink, so the package is automatically updated, when files are changed. It can then be called in a python console.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file zimbraweb-2.0.2.tar.gz
.
File metadata
- Download URL: zimbraweb-2.0.2.tar.gz
- Upload date:
- Size: 83.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 801dfa8607455949aa0f04c8c3fde94d095a2c01fe79a4ed4fbbcb57ea7dacd3 |
|
MD5 | 88580603340d99e3d252a642223a9b8a |
|
BLAKE2b-256 | 92e49dd092d0caf341512270bcb79d8615b3e0657fc875007dca59bd7d1f19fa |
File details
Details for the file zimbraweb-2.0.2-py3-none-any.whl
.
File metadata
- Download URL: zimbraweb-2.0.2-py3-none-any.whl
- Upload date:
- Size: 20.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 939158068ba4094c01b9511c9e00452890f93df63797c76916dbbd647e5247f3 |
|
MD5 | b13806ac89e04df127bcd7d14ea0e15f |
|
BLAKE2b-256 | 745bca60dba7ccc6a12f601c6d652e3a8c87240e5e35bcb483bd566932d932ef |