[Mailman-Users] Where in the code is the message footer added?

Mark Sapiro mark at msapiro.net
Sat Apr 21 03:11:04 CEST 2012


C Nulk wrote:
>
>What I would like to do is give the message footer attachment a name. 
>That way instead of seeing 'Part.002', the users will see
>'Unsubscribe'.  Maybe that will help, maybe not but it is one more step
>to make it a little more visible for the users.  I am guessing I can use
>'Content-filename: <name>' to give the attachment and name.  The
>question is where in the code do I add the change?


There's no such header as Content-Filename:.

If you want to do this by hacking code, look at
Mailman/Handlers/Decorate.py.

You will find two places in the code which look like

        if footer:
            mimeftr = MIMEText(footer, 'plain', lcset)
            mimeftr['Content-Disposition'] = 'inline'
            payload.append(mimeftr)

That's the first. The second looks the same but is indented 4 spaces
less. There are also similar "if header:" blocks, but presumably you
aren't interested in those.

Now as to what to do, that's a bit tricky because parts aren't expected
to have names unless they are attachments, not inline, but changing
the Content-Disposition: to 'attachment' will likely break the inline
display in those MUAs that do it right.

So I suggest an experiment.

change

mimeftr['Content-Disposition'] = 'inline'

to

mimeftr['Content-Disposition'] = 'inline; filename="List Unsub.txt"'

but indented as the original in both places.

You could also add another line indented at the same level as the above
line

mimeftr.set_param('name', 'List Unsub.txt')

to set the name= parameter on the Content-Type: header. See
<http://en.wikipedia.org/wiki/MIME#Content-Disposition> for example
for why you might do both. Note that this article says using a name=
parameter on Content-Type: INSTEAD of a filename= on
Content-Disposition: is discouraged, but you would be doing both which
is different. Besides, by definition you are dealing with a broken MUA
if it doesn't display the 'inline' parts in line, so give it all the
help you can.

Of course, the name "List Unsub.txt" can be whatever you want, but a
.txt extension is a good idea.

-- 
Mark Sapiro <mark at msapiro.net>        The highway is for gamblers,
San Francisco Bay Area, California    better use your sense - B. Dylan



More information about the Mailman-Users mailing list