Exemplo n.º 1
0
def process(mlist, msg, msgdata):
    # This is the negation of we're wrapping because dmarc_moderation_action
    # is wrap this message or from_is_list applies and is wrap.
    if not (msgdata.get('from_is_list') == 2 or
            (mlist.from_is_list == 2 and msgdata.get('from_is_list') == 0)):
        # Now see if we need to add a From: and/or Reply-To: without wrapping.
        a_h = msgdata.get('add_header')
        if a_h:
            if a_h.get('From'):
                del msg['from']
                msg['From'] = a_h.get('From')
            if a_h.get('Reply-To'):
                del msg['reply-to']
                msg['Reply-To'] = a_h.get('Reply-To')
        return

    # There are various headers in msg that we don't want, so we basically
    # make a copy of the msg, then delete almost everything and set/copy
    # what we want.
    omsg = copy.deepcopy(msg)
    for key in msg.keys():
        if key.lower() not in KEEPERS:
            del msg[key]
    msg['MIME-Version'] = '1.0'
    msg['Content-Type'] = 'message/rfc822'
    msg['Content-Disposition'] = 'inline'
    msg['Message-ID'] = unique_message_id(mlist)
    # Add the headers from CookHeaders.
    for k, v in msgdata['add_header'].items():
        msg[k] = v
    # And set the payload.
    msg.set_payload(omsg.as_string())
Exemplo n.º 2
0
def process(mlist, msg, msgdata):
    # Always remove this header from any outgoing messages.  Be sure to do
    # this after the information on the header is actually used, but before a
    # permanent record of the header is saved.
    del msg['approved']
    # Remove this one too.
    del msg['approve']
    # And these too.
    del msg['x-approved']
    del msg['x-approve']
    # Also remove this header since it can contain a password
    del msg['urgent']
    # If we're anonymizing, we need to save the sender here, and we may as
    # well do it for all.
    msgdata['original_sender'] = msg.get_sender()
    # We remove other headers from anonymous lists
    if mlist.anonymous_list:
        syslog('post', 'post to %s from %s anonymized', mlist.internal_name(),
               msg.get('from'))
        del msg['from']
        del msg['reply-to']
        del msg['sender']
        del msg['organization']
        del msg['return-path']
        # Hotmail sets this one
        del msg['x-originating-email']
        # And these can reveal the sender too
        del msg['received']
        # And so can the message-id so replace it.
        del msg['message-id']
        msg['Message-ID'] = unique_message_id(mlist)
        # And something sets this
        del msg['x-envelope-from']
        # And now remove all but the keepers.
        remove_nonkeepers(msg)
        i18ndesc = str(uheader(mlist, mlist.description, 'From'))
        msg['From'] = formataddr((i18ndesc, mlist.GetListEmail()))
        msg['Reply-To'] = mlist.GetListEmail()
        uf = msg.get_unixfrom()
        if uf:
            uf = re.sub(r'\S*@\S*', mlist.GetListEmail(), uf)
            msg.set_unixfrom(uf)
    # Some headers can be used to fish for membership
    del msg['return-receipt-to']
    del msg['disposition-notification-to']
    del msg['x-confirm-reading-to']
    # Pegasus mail uses this one... sigh
    del msg['x-pmrqc']
Exemplo n.º 3
0
def process(mlist, msg, msgdata):
    # Always remove this header from any outgoing messages.  Be sure to do
    # this after the information on the header is actually used, but before a
    # permanent record of the header is saved.
    del msg['approved']
    # Remove this one too.
    del msg['approve']
    # And these too.
    del msg['x-approved']
    del msg['x-approve']
    # Also remove this header since it can contain a password
    del msg['urgent']
    # If we're anonymizing, we need to save the sender here, and we may as
    # well do it for all.
    msgdata['original_sender'] = msg.get_sender()
    # We remove other headers from anonymous lists
    if mlist.anonymous_list:
        syslog('post', 'post to %s from %s anonymized',
               mlist.internal_name(), msg.get('from'))
        del msg['from']
        del msg['reply-to']
        del msg['sender']
        del msg['organization']
        del msg['return-path']
        # Hotmail sets this one
        del msg['x-originating-email']
        # And these can reveal the sender too
        del msg['received']
        # And so can the message-id so replace it.
        del msg['message-id']
        msg['Message-ID'] = unique_message_id(mlist)
        # And something sets this
        del msg['x-envelope-from']
        # And now remove all but the keepers.
        remove_nonkeepers(msg)
        i18ndesc = str(uheader(mlist, mlist.description, 'From'))
        msg['From'] = formataddr((i18ndesc, mlist.GetListEmail()))
        msg['Reply-To'] = mlist.GetListEmail()
        uf = msg.get_unixfrom()
        if uf:
            uf = re.sub(r'\S*@\S*', mlist.GetListEmail(), uf)
            msg.set_unixfrom(uf)
    # Some headers can be used to fish for membership
    del msg['return-receipt-to']
    del msg['disposition-notification-to']
    del msg['x-confirm-reading-to']
    # Pegasus mail uses this one... sigh
    del msg['x-pmrqc']
Exemplo n.º 4
0
def process(mlist, msg, msgdata):
    if not mm_cfg.ALLOW_FROM_IS_LIST or mlist.from_is_list != 2:
        return

    # There are various headers in msg that we don't want, so we basically
    # make a copy of the msg, then delete almost everything and set/copy
    # what we want.
    omsg = copy.deepcopy(msg)
    for key in msg.keys():
        if key.lower() not in KEEPERS:
            del msg[key]
    msg['MIME-Version'] = '1.0'
    msg['Content-Type'] = 'message/rfc822'
    msg['Content-Disposition'] = 'inline'
    msg['Message-ID'] = unique_message_id(mlist)
    # Add the headers from CookHeaders.
    for k, v in msgdata['add_header'].items():
        msg[k] = v
    # And set the payload.
    msg.set_payload(omsg.as_string())
Exemplo n.º 5
0
    subj = cgidata.getvalue('subject','').strip()
    body = cgidata.getvalue('text','').strip()
    if not ('.' in addr and '@' in addr ):
        showpost(mlist,language,'Please put your email address into Sender field. "Full Name <[email protected]>" is accepted too, max. 100 chars.')
        return

    msg = MIMEMultipart('mixed')
    try:
        msg['From'] = Header(addr,'ascii')
        msg['Subject'] = Header(subj,'ascii') if subj else '(No subject)'
    except:
        showpost(mlist,language,'Only ASCII chars are supported in sender and subject!')
        return
        
    msg['To'] = mlist.getListAddress()
    msgid = unique_message_id(mlist)
    msg['Message-ID'] = msgid;
    msg['Date'] = formatdate(localtime=True)
    if body:
        part = MIMEText(body, 'plain', 'utf-8')
        msg.attach(part)
    attnum = 1
    while attnum < 99:
        try:
            att = cgidata["attachment%02d" % attnum]
        except KeyError:
            break
        if att.filename:
            #Browser should send right mimetypes
            (maintype, subtype) = att.type.split('/')
            opt = att.type_options;