improve quarantine milter action
This commit is contained in:
@@ -296,6 +296,9 @@ class ModifyMilter(Milter.Base):
|
|||||||
f"current template variables: {self.msginfo['vars']}")
|
f"current template variables: {self.msginfo['vars']}")
|
||||||
if milter_action is not None:
|
if milter_action is not None:
|
||||||
break
|
break
|
||||||
|
elif not self.msginfo["rcpts"]:
|
||||||
|
milter_action = ("DISCARD", None)
|
||||||
|
break
|
||||||
|
|
||||||
if milter_action is None:
|
if milter_action is None:
|
||||||
self._replacebody()
|
self._replacebody()
|
||||||
@@ -303,6 +306,7 @@ class ModifyMilter(Milter.Base):
|
|||||||
action, reason = milter_action
|
action, reason = milter_action
|
||||||
if action == "ACCEPT":
|
if action == "ACCEPT":
|
||||||
self._replacebody()
|
self._replacebody()
|
||||||
|
return Milter.ACCEPT
|
||||||
elif action == "REJECT":
|
elif action == "REJECT":
|
||||||
self.setreply("554", "5.7.0", reason)
|
self.setreply("554", "5.7.0", reason)
|
||||||
return Milter.REJECT
|
return Milter.REJECT
|
||||||
|
|||||||
@@ -395,7 +395,7 @@ class Quarantine:
|
|||||||
self._milter_action = None
|
self._milter_action = None
|
||||||
if "milter_action" in cfg["args"]:
|
if "milter_action" in cfg["args"]:
|
||||||
self._milter_action = cfg["args"]["milter_action"].upper()
|
self._milter_action = cfg["args"]["milter_action"].upper()
|
||||||
assert self._milter_action in ["ACCEPT", "REJECT"], \
|
assert self._milter_action in ["ACCEPT", "REJECT", "DISCARD"], \
|
||||||
f"invalid milter_action '{cfg['args']['milter_action']}'"
|
f"invalid milter_action '{cfg['args']['milter_action']}'"
|
||||||
|
|
||||||
self._reason = None
|
self._reason = None
|
||||||
@@ -513,5 +513,6 @@ class Quarantine:
|
|||||||
|
|
||||||
if self._milter_action is not None:
|
if self._milter_action is not None:
|
||||||
milter.delrcpt(rcpts)
|
milter.delrcpt(rcpts)
|
||||||
if not milter.msginfo["rcpts"]:
|
if self._milter_action in ["ACCEPT", "REJECT"] and \
|
||||||
|
not milter.msginfo["rcpts"]:
|
||||||
return (self._milter_action, self._reason)
|
return (self._milter_action, self._reason)
|
||||||
|
|||||||
Reference in New Issue
Block a user