mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-12-02 12:13:54 +01:00
New plugin that allows the handling of an Amavisd-new SQL quarantine. NB: a DB connections manager has been added inside the lib because Django does not support multiple connections at the same time. The main consequence is that we don't use an ORM and that we have to rewrite a small wrapper that supports several DB (mysql, postgresql, etc.). Adding a dependancy to an existing ORM module (like SQLalchemy) is heavy, we don't want that for now.
46 lines
1.1 KiB
Python
46 lines
1.1 KiB
Python
# -*- coding: utf-8 -*-
|
|
|
|
"""
|
|
Postfix auto-replies plugin.
|
|
|
|
This module provides a way to integrate MailNG auto-reply
|
|
functionality into Postfix.
|
|
|
|
"""
|
|
from mailng.lib import events
|
|
from models import Transport, Alias
|
|
|
|
def init():
|
|
events.register("CreateDomain", onCreateDomain)
|
|
events.register("DeleteDomain", onDeleteDomain)
|
|
events.register("CreateMailbox", onCreateMailbox)
|
|
events.register("DeleteMailbox", onDeleteMailbox)
|
|
|
|
def urls():
|
|
return ()
|
|
|
|
def onCreateDomain(**kwargs):
|
|
dom = kwargs["dom"]
|
|
transport = Transport()
|
|
transport.domain = "autoreply.%s" % dom.name
|
|
transport.method = "autoreply:"
|
|
transport.save()
|
|
|
|
def onDeleteDomain(**kwargs):
|
|
dom = kwargs["dom"]
|
|
trans = Transport.objects.get(domain="autoreply.%s" % dom.name)
|
|
trabs.delete()
|
|
|
|
def onCreateMailbox(**kwargs):
|
|
mbox = kwargs["mbox"]
|
|
alias = Alias()
|
|
alias.full_address = mbox.full_address
|
|
alias.autoreply_address = \
|
|
"%s@autoreply.%s" % (mbox.full_address, mbox.domain.name)
|
|
alias.save()
|
|
|
|
def onDeleteMailbox(**kwargs):
|
|
mbox = kwargs["mbox"]
|
|
alias = Alias.objects.get(full_address=mbox.full_address)
|
|
alias.delete()
|