#!/usr/bin/env python3 # A script to automatically add mail hosts with dynamic DNS to Mailcow. # Please add it to the crontab of a user on your *Mailcow* server. # Environment variables: # MAILCOW_AWL_HOSTS: the DNS hosts you want to add, comma-separated # MAILCOW_AWL_NOTIFY: the e-mail you want to receive notifications at. This is mandatory # MAILCOW_AWL_NOTIFY: import requests import json import dns.query import os from typing import List import smtplib class Config(object): hosts: List[str] notify_email: str api_key: str def __init__(self): hosts = os.getenv('MAILCOW_AWL_HOSTS') if hosts: self.hosts = hosts.split(',') self.hosts = os.getenv('MAILCOW_AWL_HOSTS').split(',') self.notify_email = os.environ('MAILCOW_AWL_NOTIFY')