Hi everyone! Does Grommunio have a python library for writing simple automation code?
Using the community edition on Debian, and ported over my small 3 user server from Kopano. Everything is working OK, and now I'd like to replicate some automations from Kopano to Grommunio. Example, the script below finds messages older than X days in a user's inbox and moves them to an archive folder. (yes this can be achieved with python IMAP libraries, but it seems neater to implement it natively and also saves resource by not enabling IMAP for that user).
TL;DR = Looking for a Grommunio python library that I can use instead of "import kopano" in code like below:
#!/usr/bin/python3
import argparse, datetime, kopano, os, re, yaml
from datetime import datetime
# code to load config and parse args not shown to save space
def main( server, args, usersets ):
for users in usersets:
for user in users:
# Start by naming our user
print("Starting",user['method'],"of items over",user['maxage'],"days old for",user['name'])
# Initialise variables
count = 0
today = datetime.today()
store = server.user(user['name']).store
# Connect to this user's folders
if user['method'] == 'deletion':
f_inbox = store.folder('Inbox')
f_deleted = store.folder('Deleted Items')
elif user['method'] == 'archiving':
f_inbox = store.folder('Inbox')
f_archive = store.folder('Archive')
f_adverts = store.folder('Advertising')
else:
print( " Invalid method ",user['method']," requested for user ",user['name'] )
# Iterate through the message list
for item in f_inbox:
age = today - item.received
days = age.days
if days > user['maxage']:
if user['method'] == 'deletion':
item.move(f_deleted)
if( args['verbose'] is True): print("DELETED ",str(days)," old -- ", item.subject)
elif user['method'] == 'archiving':
item.move(f_archive)
if( args['verbose'] is True): print("MOVED ",str(days)," old -- ", item.subject)
count+=1
`