munpack

extracts files from MIME-encoded messages

TLDR

Extract MIME attachments
$ munpack [message.mime]
Extract from stdin
$ cat [email.eml] | munpack
Extract to specific directory
$ munpack -C [output_dir] [message.mime]
Quiet mode
$ munpack -q [message.mime]
Force overwrite
$ munpack -f [message.mime]

SYNOPSIS

munpack [options] [files...]

DESCRIPTION

munpack extracts files from MIME-encoded messages. It decodes base64 and quoted-printable content and saves attachments as separate files.munpack is the companion to mpack and handles multipart MIME messages.

PARAMETERS

-f

Force overwrite existing files.
-q
Quiet mode.
-t
Text mode (convert newlines).
-C dir
Extract to directory.

EXAMPLE

$ # Extract from email
munpack saved_email.eml

# Extract from mailbox
formail -s munpack < mbox

# Extract to specific folder
munpack -C ~/attachments email.mime

SUPPORTED ENCODINGS

$ - Base64
- Quoted-printable
- Uuencode (legacy)
- BinHex (legacy)

INSTALL

sudo apt install mpack
brew install mpack
nix profile install nixpkgs#mpack

CAVEATS

Filenames may be sanitized. Nested MIME may need multiple passes. Some legacy encodings not fully supported.

HISTORY

munpack was written by John G. Myers at Carnegie Mellon University as part of the MIME utilities for handling email attachments.

SEE ALSO

mpack(1), uudecode(1), base64(1), ripmime(1)