Package: zimbraweb
Python Zimbra WebbranchstatusmaindevelopUsageFor the entire documentation please seehttps://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 useZimbraUserto send E-mails. You can send multiple E-mails within a single session.fromzimbrawebimportZimbraUseruser=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 EMLsPlease note theLimitationswhen trying to parse EML.fromzimbrawebimportZimbraUseruser=ZimbraUser("https://myzimbra.server")user.login("s000000","hunter2")emlstr=open("myemlfile.eml").read()user.send_eml(emlstr)Sending raw WebkitPayloadsIf you don't want to rely on us to generate the payload, you can generate a payload yourself and send it usingfromzimbrawebimportZimbraUseruser=ZimbraUser("https://myzimbra.server")user.login("s000000","hunter2")# you could also generate the payload yourself or use our libraryraw_payload,boundary=user.generate_webkit_payload(to="to@example.com",subject="hello world!",body="this is a raw payload.")# then send the raw_payload bytesuser.send_raw_payload(raw_payload,boundary)user.logout()AttachmentsYou can generate attachments using theWebkitAttachmentclass:fromzimbrawebimportZimbraUser,WebkitAttachmentuser=ZimbraUser("https://myzimbra.server")user.login("s000000","hunter2")attachments=[]withopen("myfile.jpg","rb")asf: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 LimitationsEmoji is not supported, even though other UTF-8 characters are. See Issue #3This 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 #43The EML parsing can strictly only parse plaintext emails, optionally with attachments. Any emails with a Content-Type other thantext/plainormultipart/mixedwill be rejected. This is because the zimbra web interface does not allow HTML emails. Parsingmultipart/mixedwill only succeed if there is exactly onetext/plainpart and, optionally, attachments with theContent-Disposition: attachmentheader. If there are anymultipart/alternativeparts, the parsing will fail because we cannot deliver them to the Zimbra web interface.Installpip install zimbrawebContributingBest 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-requirementspip install -r requirements_dev.txtWhen working on a new feature, checkout togit branch -b feature_myfeaturename. We are usingthis branching modelBefore committing, checkmypy srcreturns no failures.flake8 src testsreturns no problems.pytesthas no unexpected failed tests.Optionoally, test withtox. Might take a few minutes so maybe only run before push.Development Install$gitclonehttps://github.com/TINF21CS1/python-zimbra-web/
$cdpython-zimbra-web
$pipinstall-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.