O'Reilly logo

Linux Pocket Guide, 2nd Edition by Daniel J. Barrett

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

metamail — stdin  stdout  - file  -- opt  --help  --version

Synopsis

metamail [options] mail_file

Modern email programs can send and receive attachments so easily we rarely think about it, but this was not always the case. Programs like metamail were created to work with attachments directly on the command line, appending or extracting them to and from mail messages. For example, if you have an email message in a file, mymessage, and it contains a JPEG image as an attachment, metamail can extract the image:

$ metamail -w mymessage
Content-Description: coolcat.jpg
This message contains 'image/jpeg`-format data.
Please enter the name of a file to which the data should
 be written (Default: coolcat.jpg) > hotdog.jpg
Wrote file hotdog.jpg

Here we extracted the attached JPEG file, coolcat.jpg, renaming it as hotdog.jpg. The -w option tells metamail to write the data to a file; otherwise, metamail would attempt to display the attachment with an appropriate program, such as an image viewer:

$ metamail mymessage
This message contains 'image/jpeg'-format data.
Do you want to view it using the 'xv' command (y/n) [y] y
---Executing: gthumb

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required