Mailman Ver: 2.1.5

Our company now exclusively uses Mailman for it's departmental mailing
lists and it's done through umbrella lists set up in the same way as the
org chart for the company.

I have managed to stop all sub-lists from re-archiving mails that have
been through higher lists by adding an X-No-Archive to mails as soon as
they're archived so that they only get archived once.

However, Subject Prefixes are giving me a little more hassle.

Currently, if a message goes through the lists "ListA, ListB and ListC"
on their way to a recipient, the subject line looks like this:

Subject: [ListC][ListB][ListA] $subject

This is getting to be an annoyance for many within the company and I
would like to get it to ONLY add a subject prefix if it's the first list
it's been through. So, if you send to ListA, you get [ListA] instead of
[ListC][ListB][ListA] and if you send to ListB you get [ListB] instead
of [ListC][ListB].

I have spent a lot of time looking for a solution to this one, but the
only solution I found is one from 1999 that might or might not work for
this version of Mailman, but my lack of Python skill is letting me down
in working it out.

Can anyone offer any help on this?

Roll-on Mailman v3!
--
Kind Regards,

__________________________________________________

Mike Peachey, IT
Tel: +44 114 281 2655
Fax: +44 114 281 2951
Jennic Ltd, Furnival Street, Sheffield, S1 4QT, UK
Comp Reg No: 3191371 - Registered In England
http://www.jennic.com
__________________________________________________

Search Discussions

  • Mark Sapiro at Sep 20, 2007 at 6:30 pm

    Mike Peachey wrote:
    I have managed to stop all sub-lists from re-archiving mails that have
    been through higher lists by adding an X-No-Archive to mails as soon as
    they're archived so that they only get archived once.

    However, Subject Prefixes are giving me a little more hassle.

    Currently, if a message goes through the lists "ListA, ListB and ListC"
    on their way to a recipient, the subject line looks like this:

    Subject: [ListC][ListB][ListA] $subject

    This is getting to be an annoyance for many within the company and I
    would like to get it to ONLY add a subject prefix if it's the first list
    it's been through. So, if you send to ListA, you get [ListA] instead of
    [ListC][ListB][ListA] and if you send to ListB you get [ListB] instead
    of [ListC][ListB].

    I have spent a lot of time looking for a solution to this one, but the
    only solution I found is one from 1999 that might or might not work for
    this version of Mailman, but my lack of Python skill is letting me down
    in working it out.

    If you yould tell us what the 1999 solution is or give a link to it, we
    might be able to tell you if it applies.

    However, here's a solution. IIRC, you are using a custom handler to add
    the X-No-Archive: header to mail sent from a list so it is received by
    subsequent lists with the header and not archived. Thus, you already
    have the presence of this header to know if a message has been through
    a prior list. And, if you're concerned about the possibility of a
    message arriving at the first list with an X-No-Archive: header
    already there, you could add an X-Mailman-No-Prefix: or some such
    header too.

    Now given that the message has a header that identifies it as one not
    wanting to be prefixed you need to modify
    Mailman/Handlers/CookHeaders.py as follows:

    Find the lines (watch for wrapping)

    def prefix_subject(mlist, msg, msgdata):
    # Add the subject prefix unless the message is a digest or is being
    fast
    # tracked (e.g. internally crafted, delivered to a single user such
    as the
    # list admin).
    prefix = mlist.subject_prefix

    and add two lines after the comment so it becomes

    def prefix_subject(mlist, msg, msgdata):
    # Add the subject prefix unless the message is a digest or is being
    fast
    # tracked (e.g. internally crafted, delivered to a single user such
    as the
    # list admin).
    if msg.get('x-no-archive', None) == None:
    return
    prefix = mlist.subject_prefix

    If you decide to use a header other than X-No-Archive:, you'd replace
    'x-no-archive' above with the name of that header.

    --
    Mark Sapiro <msapiro at value.net> The highway is for gamblers,
    San Francisco Bay Area, California better use your sense - B. Dylan
  • Mike Peachey at Sep 21, 2007 at 8:41 am

    Mark Sapiro wrote:
    Find the lines (watch for wrapping)

    def prefix_subject(mlist, msg, msgdata):
    # Add the subject prefix unless the message is a digest or is being
    fast
    # tracked (e.g. internally crafted, delivered to a single user such
    as the
    # list admin).
    prefix = mlist.subject_prefix

    and add two lines after the comment so it becomes

    def prefix_subject(mlist, msg, msgdata):
    # Add the subject prefix unless the message is a digest or is being
    fast
    # tracked (e.g. internally crafted, delivered to a single user such
    as the
    # list admin).
    if msg.get('x-no-archive', None) == None:
    return
    prefix = mlist.subject_prefix

    If you decide to use a header other than X-No-Archive:, you'd replace
    'x-no-archive' above with the name of that header.
    Thank you Mark you wonderful genius - what would this list be without
    your input? That's just the solution I was looking for, but was being
    put off-track by the 1999 solution which, for reference, is here:

    http://mail.python.org/pipermail/mailman-developers/1999-September/005936.html
    --
    Kind Regards,

    __________________________________________________

    Mike Peachey, IT
    Tel: +44 114 281 2655
    Fax: +44 114 281 2951
    Jennic Ltd, Furnival Street, Sheffield, S1 4QT, UK
    Comp Reg No: 3191371 - Registered In England
    http://www.jennic.com
    __________________________________________________
  • Mark Sapiro at Sep 21, 2007 at 2:40 pm

    Mike Peachey wrote:
    Mark Sapiro wrote:
    and add two lines after the comment so it becomes

    def prefix_subject(mlist, msg, msgdata):
    # Add the subject prefix unless the message is a digest or is being
    fast
    # tracked (e.g. internally crafted, delivered to a single user such
    as the
    # list admin).
    if msg.get('x-no-archive', None) == None:
    return
    prefix = mlist.subject_prefix

    If you decide to use a header other than X-No-Archive:, you'd replace
    'x-no-archive' above with the name of that header.
    That's just the solution I was looking for, but was being
    put off-track by the 1999 solution ...

    Ooops...


    The code above contains a mistake. It will prefix the subject only for
    messages that DO have the X-No-Archive: header. What you want in the
    if test is

    if msg.get('x-no-archive', None) <> None:
    return

    to skip the prefix if the header is not None. Those double negatives
    will get you every time. ;-)

    --
    Mark Sapiro <msapiro at value.net> The highway is for gamblers,
    San Francisco Bay Area, California better use your sense - B. Dylan
  • Mike Peachey at Sep 21, 2007 at 2:43 pm

    Mark Sapiro wrote:
    Mike Peachey wrote:
    Mark Sapiro wrote:
    and add two lines after the comment so it becomes

    def prefix_subject(mlist, msg, msgdata):
    # Add the subject prefix unless the message is a digest or is being
    fast
    # tracked (e.g. internally crafted, delivered to a single user such
    as the
    # list admin).
    if msg.get('x-no-archive', None) == None:
    return
    prefix = mlist.subject_prefix

    If you decide to use a header other than X-No-Archive:, you'd replace
    'x-no-archive' above with the name of that header.
    That's just the solution I was looking for, but was being
    put off-track by the 1999 solution ...

    Ooops...


    The code above contains a mistake. It will prefix the subject only for
    messages that DO have the X-No-Archive: header. What you want in the
    if test is

    if msg.get('x-no-archive', None) <> None:
    return

    to skip the prefix if the header is not None. Those double negatives
    will get you every time. ;-)
    I'm using this anyway :-)

    if msg.has_key('x-no-subject-prefix') and msg.get('x-no-subject-prefix',
    '').lower() == 'yes':
    --
    Kind Regards,

    __________________________________________________

    Mike Peachey, IT
    Tel: +44 114 281 2655
    Fax: +44 114 281 2951
    Jennic Ltd, Furnival Street, Sheffield, S1 4QT, UK
    Comp Reg No: 3191371 - Registered In England
    http://www.jennic.com
    __________________________________________________
  • Mark Sapiro at Sep 21, 2007 at 2:56 pm

    Mike Peachey wrote:
    I'm using this anyway :-)

    if msg.has_key('x-no-subject-prefix') and msg.get('x-no-subject-prefix',
    '').lower() == 'yes':

    You don't need to test separately for the presence of the header.
    That's what the second argument to msg.get() is for. It is returned
    when the header named in the first argument isn't present, so the
    above can be simplified to

    if msg.get('x-no-subject-prefix', '').lower() == 'yes':

    which is true if and only if there is an 'x-no-subject-prefix' header
    with value 'yes'

    --
    Mark Sapiro <msapiro at value.net> The highway is for gamblers,
    San Francisco Bay Area, California better use your sense - B. Dylan
  • Mike Peachey at Sep 21, 2007 at 3:35 pm

    Mark Sapiro wrote:
    Mike Peachey wrote:
    I'm using this anyway :-)

    if msg.has_key('x-no-subject-prefix') and msg.get('x-no-subject-prefix',
    '').lower() == 'yes':

    You don't need to test separately for the presence of the header.
    That's what the second argument to msg.get() is for. It is returned
    when the header named in the first argument isn't present, so the
    above can be simplified to

    if msg.get('x-no-subject-prefix', '').lower() == 'yes':

    which is true if and only if there is an 'x-no-subject-prefix' header
    with value 'yes'
    Ta.
    --
    Kind Regards,

    __________________________________________________

    Mike Peachey, IT
    Tel: +44 114 281 2655
    Fax: +44 114 281 2951
    Jennic Ltd, Furnival Street, Sheffield, S1 4QT, UK
    Comp Reg No: 3191371 - Registered In England
    http://www.jennic.com
    __________________________________________________

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupmailman-users @
categoriespython
postedSep 20, '07 at 9:05a
activeSep 21, '07 at 3:35p
posts7
users2
websitelist.org

2 users in discussion

Mike Peachey: 4 posts Mark Sapiro: 3 posts

People

Translate

site design / logo © 2022 Grokbase