[Mailman-Users] Importing archived msgs into a Mailman list

Mark Sapiro mark at msapiro.net
Tue Jun 14 14:06:37 EDT 2016

On 06/14/2016 10:51 AM, John Poltorak wrote:
> I think each msg starts with *Return-Path:*
> so I guess I need to insert an extra line at the start of each msg...
> A simple sed script should suffice to convert each msg. Do I just need
> to insert '*From *'  as the first line of each msg?

Ideally, you insert

'From address date`

where address is the address without the <> from the Return-Path: and
date is the string produced by the 'date' command.

The attached addfrom script is what I use. It's overly complex for your
purpose and converts one message in one file in place. You could
probably adapt it to your purpose.

Mark Sapiro <mark at msapiro.net>        The highway is for gamblers,
San Francisco Bay Area, California    better use your sense - B. Dylan
-------------- next part --------------
#! /bin/bash
# Convert a single saved email with a Return-Path: as its first line
# to a mailbox by adding a From_
if [ ! -w "$1" ]; then
  echo usage: addfrom file
head -1 "$1" > $f1
if grep -q -i -e "^From " $f1 ; then
  echo File already has From_ line
  rm $f1 $f2
if ! grep -q -i -e "^return-path:" $f1 ; then
  echo "Return-Path: <bogus at example.com>" > $f1
sed -e "s/^.*</From /" -e "s/>.*/  $d/" <$f1 >$f2
# strip any trailing <cr>s
sed -e 's/\r$//' < "$1" >> $f2
# make sure we have a trailing empty line
echo >$f1
cat $f2 $f1 $f1 > "$1"
rm $f1 $f2

More information about the Mailman-Users mailing list