~phil.pennock/mailman/dmarc-reject

« back to all changes in this revision

Viewing changes to Mailman/Handlers/Moderate.py

  • Committer: Jim Popovitch
  • Date: 2013-03-03 08:04:37 UTC
  • Revision ID: jimpop@gmail.com-20130303080437-rjqvq4cas36ieqv5
Hold/Reject/Discard moderation support for Senders with a DMARC p=reject policy

Show diffs side-by-side

added added

removed removed

Lines of Context:
56
56
    else:
57
57
        sender = None
58
58
    if sender:
 
59
        if Utils.IsDmarcProhibited(sender):
 
60
            # Note that for dmarc_moderation_action, 0==Hold, 1=Reject,
 
61
            # 2==Discard
 
62
            if mlist.dmarc_moderation_action == 0:
 
63
                msgdata['sender'] = sender
 
64
                Hold.hold_for_approval(mlist, msg, msgdata,
 
65
                                       ModeratedMemberPost)
 
66
            elif mlist.dmarc_moderation_action == 1:
 
67
                # Reject
 
68
                text = mlist.dmarc_moderation_notice
 
69
                if text:
 
70
                    text = Utils.wrap(text)
 
71
                else:
 
72
                    # Use the default RejectMessage notice string
 
73
                    text = None
 
74
                raise Errors.RejectMessage, text
 
75
            elif mlist.dmarc_moderation_action == 2:
 
76
                raise Errors.DiscardMessage
 
77
            else:
 
78
                assert 0, 'bad dmarc_moderation_action'
 
79
 
 
80
            # sender's domain has a 'p=reject' _dmarc TXT record,
 
81
            # we should NOT automatically reflect this email
 
82
            return
 
83
 
59
84
        # If the member's moderation flag is on, then perform the moderation
60
85
        # action.
61
86
        if mlist.getMemberOption(sender, mm_cfg.Moderate):