modoboa / modoboa-postfix-autoreply

Away message editor for Modoboa (postfix compatible)
MIT License
6 stars 9 forks source link

Autoreply only for direct message and not alias #49

Open twagener opened 7 years ago

twagener commented 7 years ago

It would be great to check if the original mail goes to a alias-list or is only for me. So auto reply won't answer for a mail which was not only for me and was sent to an alias

twagener commented 7 years ago

i made it working for me... if anyone needs this - change it like this:

i added the original_recipient option in env/lib/python2.7/site-packages/modoboa_postfix_autoreply/management/commands

`def add_arguments(self, parser): """Add extra arguments to command line.""" parser.add_argument( "--debug", action="store_true", dest="debug", default=True ) parser.add_argument("sender", type=unicode) parser.add_argument("recipient", type=unicode, nargs="+") parser.add_argument("original_recipient", type=unicode)

def handle(self, *args, **options):
    if options["debug"]:
        logger.setLevel(logging.DEBUG)

    logger.debug(
        "autoreply sender=%s recipient=%s orig=%s",
        options["sender"], ",".join(options["recipient"]), options["original_recipient"]
    )

    original_recipient = options["original_recipient"]
    recipient = options["recipient"]

    if ( original_recipient not in recipient ):
        logger.debug(
            "Skip auto reply, this mail was for an alias list")
        return`

and modified the master.cf from postfix like this: autoreply unix - n n - - pipe flags= user=vmail:vmail argv=/srv/modoboa/env/bin/python /srv/modoboa/instance/manage.py autoreply $sender $mailbox $original_recipient