procmail
[Top] [All Lists]

Trimming Groupwise forwarding headers

2003-12-08 16:18:08

Back in March of this year, there was some discussion of how to trim
headers generated by Novell Groupwise.  The discussion never never
reached a concise resolution, so I thought I'd contribute something for
the archives.

Novell Groupwise is a piece of corporate groupware with an add-on
package called "Groupwise Internet Agent" (GWIA) whose fecal stench
remains stunning even into beta version 6.5.2.  Groupwise itself isn't
so bad, but GWIA will melt your nose hairs if you inhale too quickly.
And it's an unfortunate fact that if you're in a company large enough to
be using Groupwise, then you probably won't be able to overcome enough
management inertia to replace it with something more sysadmin-friendly.

For folks using Groupwise who don't (or can't) run the Groupwise client
application (for Windows, though I'm told a Linux version is or may soon
be available), there are six possible ways of getting at your mail.

1 - Punt, and run the Groupwise client, in vmware if necessary.  If
    email is a big part of your work, this is not recommended.
2 - Use Groupwise web access.  This is trash, and should be avoided.
2 - Use a standard mail client, and access your Groupwise mail via IMAP.
    GWIA will break Message-IDs, corrupt headers and text/* blocks, but
    you will be able to manage your account using a familiar client.
    Again, not recommended if you do anything technical with email.
3 - Get your mail via POP3 using fetchmail, for redelivery to a unix
    host.  This has the same problems as IMAP wrt msgid and text/*,
    though it's alot easier to debug if you know how POP3 works.  (If
    you're reading this list, it's likely you'd have to "escalate to IT"
    any such problems, but at least you'd be able to identify where the
    problem lies.)
4 - Don't have a Groupwise account -- instead, have your GW admins put
    in an entry the Groupwise "master alias list" so that email to you
    will automatically be forwarded to a real account on a unix server.  
5 - Have a Groupwise account, and set up a global forwarding rule which
    sends your inbound email via SMTP to an external address.  ALSO set
    up another rule which will delete any forwarded messages from your
    "Sent Items" folder.

Item 5 is the best option all around, but requires some processing to
work.  This is because when Groupwise "forwards" the message, it does it
as a MIME-attachment.  That is, you'll receive the original message
embedded in a Groupwise message that has a "Content-type: message/rfc822"
in the header.

The processing for this is relatively simple.  If don't mind the extra
processing, or you intend to send it off-site, you can paraphrase Dman's
solution:

        :0 b # forward just the body
        * ^Subject: Fwd:
        * ^X-Mailer: Novell GroupWise Internet Agent
        * ^Content-Type: message/rfc822
        ! forward(_at_)address

The problem with this is that if you're delivering locally, it still
resubmits the message to your queue, which is a tad wasteful.  So I use
the following:

        :0 fhw
        * ^Subject: Fwd:
        * ^X-Mailer: Novell GroupWise Internet Agent
        * ^Content-Type: message/rfc822
        | sed -e '1,/^$/ d'

This strips off the "real" headers of the (forwarded) message, leaving
you with the content, which is already message/rfc822, and therefore
what you wanted in the first place.  It's necessary to do this with sed
rather than with `formail -I""` because the above sed script will also
remove the blank line between header and body, whereas formail's -I""
will merely negate all header lines, leaving the blank ... which will
remain as a separator between the (now emptied) header and the body.

Now ... there remains a problem with Message-IDs.  Groupwise doesn't
understand how Message-IDs are supposed to work -- different versions of
GWIA break standards in new an innovative ways, and cannot be relied on
either to be consistent, unique, or even there.  The above recipe will
work for email which is delivered TO Groupwise FROM the Internet,
because the original Message-ID will remain in the "body" of the
forwarded message.  But if somebody sends you a message FROM Groupwise,
the above recipe will deliver it verbatim, without a Message-ID.

Which leaves you with two choices.  If you don't care about the
nonexistence of these lines, then just leave it.  If you want them for
your own tagging (forwarding, group replies, whatever), then you can do
something like this:

        :0
        * ^Subject: Fwd:
        * ^X-Mailer: Novell GroupWise Internet Agent
        * ^Content-Type: message/rfc822
        {
         :0
         * 1^0 B ?? ^Message-ID: \/.+
         { msgid="$MATCH" }
        
         :0 E
         * ^Message-ID: \/.+
         { msgid="$MATCH" }
        
         :0 E
         * 1^0 B ?? ^Return-Path:[^(_at_)]+@\/[^>]+
         { msgid="`date '+%Y%m%d%T'`(_dot_)$$(_at_)$MATCH" }
        
         :0 E
         * ^Return-Path:[^(_at_)]+@\/[^>]+
         { msgid="`date '+%Y%m%d%T'`(_dot_)$$(_at_)$MATCH" }
        
         :0 fhw
         | sed -e '1,/^$/ d'
        
         :0 fhw
         * ! ^Message-ID:
         | formail -I"Message-ID: $msgid"
        }

The idea here is that we'll use a Message-ID if a legitimate one exists,
and create one based on the source of the message if there's not.
Precedence for the Message-ID is
- in the body (i.e. the original message, likely hit for Internet mail)
- in the header (likely hit for mail from other Groupwise clients)
- made up based on Return-Path (usually envelope-from) in header
- made up based on Return-Path (usually envelope-from) in body

I use scored conditions in the Body checks to ensure that I'll only ever
grab the "first" Message-ID (in case the embedded message contains its
own embedded messages with Message-ID lines).

The last two cases will likely never be hit ... but one can never be too
paranoid.  :)

I use Sendmail at home and Postfix at work.  If you use something else,
you may have to adjust things to suit.

-- 
  Paul Chvostek                                             
<paul(_at_)it(_dot_)ca>
  Operations / Abuse / Whatever
  it.canada, hosting and development                   http://www.it.ca/


_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

<Prev in Thread] Current Thread [Next in Thread>