Skip to main content

A Python wrapper for the Zimbra Web Interface

Project description

Python Zimbra Web

branch status
main Tests
develop Tests

Usage

For the entire documentation please see https://TINF21CS1.github.io/python-zimbra-web.

The documentation for the develop branch can be found here: https://TINF21CS1.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 or multipart/mixed will be rejected. This is because the zimbra web interface does not allow HTML emails. Parsing multipart/mixed will only succeed if there is exactly one text/plain part and, optionally, attachments with the Content-Disposition: attachment header. If there are any multipart/alternative parts, the parsing will fail because we cannot deliver them to the Zimbra web interface.

Install

pip install zimbraweb

Contributing

  1. Best practice is to develop in a python3.8 virtual env: python3.8 -m venv env, source env/bin/activate (Unix) or env\Scripts\activate.ps1 (Windows)
  2. Install dev-requirements pip install -r requirements_dev.txt
  3. When working on a new feature, checkout to git branch -b feature_myfeaturename. We are using this branching model
  4. Before committing, check
    1. mypy src returns no failures.
    2. flake8 src tests returns no problems.
    3. pytest has no unexpected failed tests.
    4. Optionoally, test with tox. Might take a few minutes so maybe only run before push.

Development Install

$ git clone https://github.com/TINF21CS1/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

zimbraweb-2.1.1.tar.gz (83.3 kB view details)

Uploaded Source

Built Distribution

zimbraweb-2.1.1-py3-none-any.whl (20.2 kB view details)

Uploaded Python 3

File details

Details for the file zimbraweb-2.1.1.tar.gz.

File metadata

  • Download URL: zimbraweb-2.1.1.tar.gz
  • Upload date:
  • Size: 83.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.9.12

File hashes

Hashes for zimbraweb-2.1.1.tar.gz
Algorithm Hash digest
SHA256 8cbc2b459eada9b4a9b183ebe1016daff63a524d600c6c63be4bb63d5972585d
MD5 e132fb36f58b99f378b573231cb105b8
BLAKE2b-256 85ebdafb417b8bbb743934f5d8eb6f5ba2da1f22b4b6bdfe685fad0a2fb07d6a

See more details on using hashes here.

File details

Details for the file zimbraweb-2.1.1-py3-none-any.whl.

File metadata

  • Download URL: zimbraweb-2.1.1-py3-none-any.whl
  • Upload date:
  • Size: 20.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.9.12

File hashes

Hashes for zimbraweb-2.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8f5e491c1f99f6c25bb6be931b903d8c1f6073761de2333ca46066fe1856c478
MD5 c1e603711e90b2675b74ea8801b0ed3e
BLAKE2b-256 685f41823d4062f133f581bc941f29e4ed48e50cdb2bcc3ea05e7c01215e564b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page