Commits

Zhang Huangbin committed acb954c

Move custom settings to settings.py instead of plugin source file.

  • Participants
  • Parent commits f00ab61

Comments (0)

Files changed (1)

File plugins/reject_sender_login_mismatch.py

 """Reject sender login mismatch (sender in mail header and SASL username).
 
-You should remove "sender_login_mismatch" in Postfix
-"smtpd_sender_restrictions" and let this plugin do it for you.
+*) You should remove "sender_login_mismatch" in Postfix
+   "smtpd_sender_restrictions" and let this plugin do it for you.
+
+*) Please list all allowed senders in in settings.py, parameter
+   ALLOWED_LOGIN_MISMATCH_SENDERS, either a list or tuple is ok.
 """
 
 import logging
 from libs import SMTP_ACTIONS
+import settings
 
 REQUIRE_LOCAL_SENDER = False
 REQUIRE_LOCAL_RECIPIENT = False
 RECIPIENT_SEARCH_ATTRLIST = []
 
 # Allow sender login mismatch for below senders.
-ALLOWED_SENDERS = []
+if 'ALLOWED_LOGIN_MISMATCH_SENDERS' in dir(settings):
+    ALLOWED_LOGIN_MISMATCH_SENDERS = settings.ALLOWED_LOGIN_MISMATCH_SENDERS
+else:
+    ALLOWED_LOGIN_MISMATCH_SENDERS = []
 
 def restriction(**kwargs):
     # The sender appears in 'From:' header.
     if sasl_username:    # Is a outgoing email
         # Compare them
         if sender != sasl_username:
-            if sasl_username in ALLOWED_SENDERS:
+            if sasl_username in ALLOWED_LOGIN_MISMATCH_SENDERS:
                 return SMTP_ACTIONS['default']
             else:
                 # Reject without reason.