A Nushell plugin for parsing MIME messages and mail streams using the mail-parser crate. This plugin is ideal for analyzing .eml files or acting as a mail filter in a pipeline.
- Build the plugin:
cargo build --release
- Add the plugin to Nushell:
plugin add target/release/nu_plugin_mime_message
- Use the plugin in your Nushell session:
plugin use mime_message
You can pipe binary or string data containing a MIME message to the mime-part command.
The plugin can be used to filter or process emails from a stream. For example, to check the subject of an incoming stream:
$in | mime-part | get subjectWhen parsing files, it is recommended to use open --raw to ensure the original MIME structure and body content are preserved (as Nushell's default .eml parsing may truncate data):
open --raw sample_email.eml | mime-partThe command outputs a record with the following fields:
subject: The subject of the email (string)from: A list of sender addresses, each containingnameandaddressfields.to: A list of recipient addresses.date: The date the email was sent, in RFC3339 format.body_text: The plain text body of the email.body_html: The HTML body of the email.attachments: A list of attachments. Each attachment record contains:filename: The name of the attached file.content_type: The MIME content type.body: The binary payload of the attachment.