From owner-freebsd-questions@FreeBSD.ORG Sat May 30 12:24:33 2009 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E3132106568F for ; Sat, 30 May 2009 12:24:33 +0000 (UTC) (envelope-from smithi@nimnet.asn.au) Received: from sola.nimnet.asn.au (paqi.nimnet.asn.au [220.233.188.227]) by mx1.freebsd.org (Postfix) with ESMTP id 66F858FC15 for ; Sat, 30 May 2009 12:24:33 +0000 (UTC) (envelope-from smithi@nimnet.asn.au) Received: from localhost (localhost [127.0.0.1]) by sola.nimnet.asn.au (8.14.2/8.14.2) with ESMTP id n4UC3GMN058789; Sat, 30 May 2009 22:03:17 +1000 (EST) (envelope-from smithi@nimnet.asn.au) Date: Sat, 30 May 2009 22:03:16 +1000 (EST) From: Ian Smith To: Vince Sabio In-Reply-To: <20090530082027.3E0FE1065686@hub.freebsd.org> Message-ID: <20090530212836.I55023@sola.nimnet.asn.au> References: <20090530082027.3E0FE1065686@hub.freebsd.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Cc: freebsd-questions@freebsd.org Subject: Re: MIME attachments in mbox files X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 30 May 2009 12:24:34 -0000 On Fri, 29 May 2009 23:40:52 -0400 Vince Sabio wrote: > I have a need (well, I have lots of needs, but I'll try to stay > focused here) to be able to take a Windows zip file that is stored as > a MIME attachment to an e-mail message in an Mbox-format spool file, > and unzip the attachment. I actually need to script the process. In > case it helps, I can dedicate a mailbox to the task. If necessary, I > can write my own parser to strip out the attachment, in which case > I'd need only a widget that can take in a MIME (base64) encoded zip > file, convert it to binary, and unzip it. > > Anyone know of any FreeBSD utility(ies) that do(es) this? /usr/ports/converters/mpack /usr/ports/archivers/unzip You could first export/save each such message to a separate file and run munpack(1) on it to extract any base64 attachment/s, then unzip(1) any identifiable zipfiles. You can most likely rely on the return code from 'unzip -t $file' to check any files are valid zipfiles, if munpack can't recover the original filename from the MIME headers. cheers, Ian