Mail files
eml parseeml parseeml headerseml headerseml attachmentseml attachmentseml createeml createeml writeeml writemsg parsemsg parsemsg to_emlmsg to_eml

eml parse <path_or_text>


Description

    Read a mail message, from a file or an inline text, into JSON: headers decoded (RFC 2047 in any charset known to Java, adjacent words joined), date with its zone, text, html, attachments with their size and SHA-256, forwarded messages

Parameters

    path_or_text:   The path of a mail file, or the raw message itself: a value with a line break (or starting like a header, ex: From: x) is the message. The parameter source (auto | path | text) forces the choice. Give a path for a message with 8-bit parts: a text is read back as UTF-8 - String - required
admin
eml parse "From: =?UTF-8?Q?=C3=89ric_L=C3=A9v=C3=AAque?= <eric@example.org> To: \"Doe, John\" <john@example.org>, Team: a@example.org, b@example.org; Subject: =?iso-8859-1?Q?caf=E9?= =?UTF-8?B?IOKCrA==?= Date: Tue, 3 Nov 2026 14:22:05 +0100 Message-ID: <m1@example.org> References: <o@example.org> <p@example.org> Hello"
mentdb
{"from": [{"name": "Éric Lévêque", "address": "eric@example.org"}], "to": [{"name": "Doe, John", "address": "john@example.org"}, {"name": null, "address": "a@example.org"}, {"name": null, "address": "b@example.org"}], "cc": [], "bcc": [], "reply_to": [], "subject": "café \u20AC", "date": "2026-11-03T14:22:05+01:00", "date_raw": "Tue, 3 Nov 2026 14:22:05 +0100", "message_id": "m1@example.org", "in_reply_to": null, "references": ["o@example.org", "p@example.org"], "text": "Hello", "html": null, "text_from_html": false, "attachments": [], "forwarded": [], "warnings": []}
Latin-1 quoted-printable text; the attacker-controlled name ../../etc/passwd becomes passwd, with a warning
admin
eml parse "From: a@example.org Subject: Report MIME-Version: 1.0 Content-Type: multipart/mixed; boundary=X --X Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable d=E9j=E0 vu --X Content-Type: text/csv Content-Disposition: attachment; filename=\"../../etc/passwd\" Content-Transfer-Encoding: base64 YSxiCjEsMgo= --X-- "
mentdb
{"from": [{"name": null, "address": "a@example.org"}], "to": [], "cc": [], "bcc": [], "reply_to": [], "subject": "Report", "date": null, "date_raw": null, "message_id": null, "in_reply_to": null, "references": [], "text": "déjà vu", "html": null, "text_from_html": false, "attachments": [{"filename": "passwd", "content_type": "text/csv", "bytes": 8, "sha256": "492d5ea496056f1a6a6592241032fab764c321596317930b4fa0e1e8bc3b7470", "inline": false, "content_id": null, "saved_path": null}], "forwarded": [], "warnings": ["the attachment name '../../etc/passwd' was changed to 'passwd'"]}
Malformed message: warnings instead of a crash
admin
eml parse "From: a@example.org Subject: =?x-unknown?Q?caf=E9?= Content-Type: multipart/mixed; boundary=X --X Content-Type: text/plain; charset=nope hello "
mentdb
{"from": [{"name": null, "address": "a@example.org"}], "to": [], "cc": [], "bcc": [], "reply_to": [], "subject": "café", "date": null, "date_raw": null, "message_id": null, "in_reply_to": null, "references": [], "text": "hello\ ", "html": null, "text_from_html": false, "attachments": [], "forwarded": [], "warnings": ["a header: unknown charset 'x-unknown', read as Windows-1252", "a multipart has no closing boundary", "a text body: unknown charset 'nope', read as UTF-8"]}
A forwarded message
admin
eml parse "From: a@example.org Subject: Fwd Content-Type: multipart/mixed; boundary=X --X See below --X Content-Type: message/rfc822 From: b@example.org Subject: Original First text --X-- "
mentdb
{"from": [{"name": null, "address": "a@example.org"}], "to": [], "cc": [], "bcc": [], "reply_to": [], "subject": "Fwd", "date": null, "date_raw": null, "message_id": null, "in_reply_to": null, "references": [], "text": "See below", "html": null, "text_from_html": false, "attachments": [], "forwarded": [{"from": [{"name": null, "address": "b@example.org"}], "to": [], "cc": [], "bcc": [], "reply_to": [], "subject": "Original", "date": null, "date_raw": null, "message_id": null, "in_reply_to": null, "references": [], "text": "First text", "html": null, "text_from_html": false, "attachments": [], "forwarded": []}], "warnings": []}
An HTML message: the raw html, and a text made without the script and without loading the image
admin
eml parse "From: a@example.org Content-Type: text/html; charset=utf-8 <html><head><style>p{}</style></head><body><script>alert(1)</script><p>One & <b>two</b></p><img src=\"http://example.org/track.png\"><ul><li>a</li><li>b</li></ul></body></html>"
mentdb
{"from": [{"name": null, "address": "a@example.org"}], "to": [], "cc": [], "bcc": [], "reply_to": [], "subject": null, "date": null, "date_raw": null, "message_id": null, "in_reply_to": null, "references": [], "text": "One & two\ \ - a\ - b", "html": "<html><head><style>p{}</style></head><body><script>alert(1)</script><p>One & <b>two</b></p><img src=\"http://example.org/track.png\"><ul><li>a</li><li>b</li></ul></body></html>", "text_from_html": true, "attachments": [], "forwarded": [], "warnings": []}

eml parse <path_or_text> <json_params>


Description

    Read a message with parameters: save_attachments_to (a directory), overwrite (false), html_to_text (true: text is made from the HTML when there is no text part), headers (false: adds every header as {name, value}), source (auto | path | text), max_message_bytes (64 MB, at most 512 MB), max_attachment_bytes (50 MB), max_parts (1000), max_depth (5, forwarded messages), max_text_chars (16 million), max_headers (2000 per part)

Parameters

    path_or_text:   The path of a mail file, or the raw message itself: a value with a line break (or starting like a header, ex: From: x) is the message. The parameter source (auto | path | text) forces the choice. Give a path for a message with 8-bit parts: a text is read back as UTF-8 - String - required
    json_params:   The parameters - String - required
admin
eml parse "From: =?UTF-8?Q?=C3=89ric_L=C3=A9v=C3=AAque?= <eric@example.org> To: \"Doe, John\" <john@example.org>, Team: a@example.org, b@example.org; Subject: =?iso-8859-1?Q?caf=E9?= =?UTF-8?B?IOKCrA==?= Date: Tue, 3 Nov 2026 14:22:05 +0100 Message-ID: <m1@example.org> References: <o@example.org> <p@example.org> Hello" "{\"headers\": true}"
mentdb
{"from": [{"name": "Éric Lévêque", "address": "eric@example.org"}], "to": [{"name": "Doe, John", "address": "john@example.org"}, {"name": null, "address": "a@example.org"}, {"name": null, "address": "b@example.org"}], "cc": [], "bcc": [], "reply_to": [], "subject": "café \u20AC", "date": "2026-11-03T14:22:05+01:00", "date_raw": "Tue, 3 Nov 2026 14:22:05 +0100", "message_id": "m1@example.org", "in_reply_to": null, "references": ["o@example.org", "p@example.org"], "text": "Hello", "html": null, "text_from_html": false, "attachments": [], "forwarded": [], "headers": [{"name": "From", "value": "Éric Lévêque <eric@example.org>"}, {"name": "To", "value": "\"Doe, John\" <john@example.org>, Team: a@example.org, b@example.org;"}, {"name": "Subject", "value": "café \u20AC"}, {"name": "Date", "value": "Tue, 3 Nov 2026 14:22:05 +0100"}, {"name": "Message-ID", "value": "<m1@example.org>"}, {"name": "References", "value": "<o@example.org> <p@example.org>"}], "warnings": []}
No text made from the HTML
admin
eml parse "From: a@example.org Content-Type: text/html; charset=utf-8 <html><head><style>p{}</style></head><body><script>alert(1)</script><p>One & <b>two</b></p><img src=\"http://example.org/track.png\"><ul><li>a</li><li>b</li></ul></body></html>" "{\"html_to_text\": false}"
mentdb
{"from": [{"name": null, "address": "a@example.org"}], "to": [], "cc": [], "bcc": [], "reply_to": [], "subject": null, "date": null, "date_raw": null, "message_id": null, "in_reply_to": null, "references": [], "text": null, "html": "<html><head><style>p{}</style></head><body><script>alert(1)</script><p>One & <b>two</b></p><img src=\"http://example.org/track.png\"><ul><li>a</li><li>b</li></ul></body></html>", "text_from_html": false, "attachments": [], "forwarded": [], "warnings": []}
A small attachment limit
admin
eml parse "From: a@example.org Subject: Report MIME-Version: 1.0 Content-Type: multipart/mixed; boundary=X --X Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable d=E9j=E0 vu --X Content-Type: text/csv Content-Disposition: attachment; filename=\"../../etc/passwd\" Content-Transfer-Encoding: base64 YSxiCjEsMgo= --X-- " "{\"max_attachment_bytes\": 3}"
mentdb
{"from": [{"name": null, "address": "a@example.org"}], "to": [], "cc": [], "bcc": [], "reply_to": [], "subject": "Report", "date": null, "date_raw": null, "message_id": null, "in_reply_to": null, "references": [], "text": "déjà vu", "html": null, "text_from_html": false, "attachments": [{"filename": "passwd", "content_type": "text/csv", "bytes": 8, "sha256": "492d5ea496056f1a6a6592241032fab764c321596317930b4fa0e1e8bc3b7470", "inline": false, "content_id": null, "too_large": true, "saved_path": null}], "forwarded": [], "warnings": ["the attachment name '../../etc/passwd' was changed to 'passwd'", "the attachment 'passwd' is larger than 3 bytes (max_attachment_bytes): it is not saved"]}
A forwarded message kept as an attachment
admin
eml parse "From: a@example.org Subject: Fwd Content-Type: multipart/mixed; boundary=X --X See below --X Content-Type: message/rfc822 From: b@example.org Subject: Original First text --X-- " "{\"max_depth\": 0}"
mentdb
{"from": [{"name": null, "address": "a@example.org"}], "to": [], "cc": [], "bcc": [], "reply_to": [], "subject": "Fwd", "date": null, "date_raw": null, "message_id": null, "in_reply_to": null, "references": [], "text": "See below", "html": null, "text_from_html": false, "attachments": [{"filename": "attachment_1.eml", "content_type": "message/rfc822", "bytes": 49, "sha256": "d7376d0577c8c6f497bccc43d20cbd46fb945c6d3f446442fa430338d59ae4c3", "inline": false, "content_id": null, "saved_path": null}], "forwarded": [], "warnings": ["a forwarded message deeper than 0 is kept as an attachment (max_depth)"]}"
Complete: the attachments saved while reading
admin
if (equal (file exist "tmp/tuto_mail") "1") {file delete "tmp/tuto_mail";}; eml write "{\"from\": \"a@example.org\", \"to\": \"b@example.org\", \"subject\": \"Report\", \"date\": \"2026-11-03T14:22:05+01:00\", \"message_id\": \"m2@example.org\", \"text\": \"See the file\", \"html\": \"<p>See the <b>file</b></p>\", \"attachments\": [{\"content_text\": \"a;b\", \"filename\": \"été.csv\"}]}" "tmp/tuto_mail/m.eml" "{\"boundary\": \"BOUNDARY\"}"; -> "[res]" (eml parse "tmp/tuto_mail/m.eml" "{\"save_attachments_to\": \"tmp/tuto_mail/in\"}"); file delete "tmp/tuto_mail"; [res]
mentdb
{"from": [{"name": null, "address": "a@example.org"}], "to": [{"name": null, "address": "b@example.org"}], "cc": [], "bcc": [], "reply_to": [], "subject": "Report", "date": "2026-11-03T14:22:05+01:00", "date_raw": "Tue, 03 Nov 2026 14:22:05 +0100", "message_id": "m2@example.org", "in_reply_to": null, "references": [], "text": "See the file", "html": "<p>See the <b>file</b></p>", "text_from_html": false, "attachments": [{"filename": "été.csv", "content_type": "text/csv", "bytes": 3, "sha256": "5719af18823567701f70e9f302f75d96e574215493286286a57b0a4959672283", "inline": false, "content_id": null, "saved_path": "tmp/tuto_mail/in/été.csv"}], "forwarded": [], "warnings": []}
Used in use cases (1 recipe)

    Files & archives manager › Read an archived mail and extract its attachments safely
Often used with

    eml attachments  ·  eml write  ·  equal  ·  file delete  ·  file exist  ·  file mkdir

eml headers <path_or_text>


Description

    Only the headers of a message, faster on a big file: the decoded fields of eml parse and every header as {name, value}. At most the first 8 MB of a file are read

Parameters

    path_or_text:   The path of a mail file, or the raw message itself: a value with a line break (or starting like a header, ex: From: x) is the message. The parameter source (auto | path | text) forces the choice. Give a path for a message with 8-bit parts: a text is read back as UTF-8 - String - required
admin
eml headers "From: =?UTF-8?Q?=C3=89ric_L=C3=A9v=C3=AAque?= <eric@example.org> To: \"Doe, John\" <john@example.org>, Team: a@example.org, b@example.org; Subject: =?iso-8859-1?Q?caf=E9?= =?UTF-8?B?IOKCrA==?= Date: Tue, 3 Nov 2026 14:22:05 +0100 Message-ID: <m1@example.org> References: <o@example.org> <p@example.org> Hello"
mentdb
{"from": [{"name": "Éric Lévêque", "address": "eric@example.org"}], "to": [{"name": "Doe, John", "address": "john@example.org"}, {"name": null, "address": "a@example.org"}, {"name": null, "address": "b@example.org"}], "cc": [], "bcc": [], "reply_to": [], "subject": "café \u20AC", "date": "2026-11-03T14:22:05+01:00", "date_raw": "Tue, 3 Nov 2026 14:22:05 +0100", "message_id": "m1@example.org", "in_reply_to": null, "references": ["o@example.org", "p@example.org"], "headers": [{"name": "From", "value": "Éric Lévêque <eric@example.org>"}, {"name": "To", "value": "\"Doe, John\" <john@example.org>, Team: a@example.org, b@example.org;"}, {"name": "Subject", "value": "café \u20AC"}, {"name": "Date", "value": "Tue, 3 Nov 2026 14:22:05 +0100"}, {"name": "Message-ID", "value": "<m1@example.org>"}, {"name": "References", "value": "<o@example.org> <p@example.org>"}], "warnings": []}

eml headers <path_or_text> <json_params>


Description

    The headers with parameters: source (auto | path | text), max_headers

Parameters

    path_or_text:   The path of a mail file, or the raw message itself: a value with a line break (or starting like a header, ex: From: x) is the message. The parameter source (auto | path | text) forces the choice. Give a path for a message with 8-bit parts: a text is read back as UTF-8 - String - required
    json_params:   The parameters - String - required
admin
eml headers "From: =?UTF-8?Q?=C3=89ric_L=C3=A9v=C3=AAque?= <eric@example.org> To: \"Doe, John\" <john@example.org>, Team: a@example.org, b@example.org; Subject: =?iso-8859-1?Q?caf=E9?= =?UTF-8?B?IOKCrA==?= Date: Tue, 3 Nov 2026 14:22:05 +0100 Message-ID: <m1@example.org> References: <o@example.org> <p@example.org> Hello" "{\"max_headers\": 2}"
mentdb
{"from": [{"name": "Éric Lévêque", "address": "eric@example.org"}], "to": [{"name": "Doe, John", "address": "john@example.org"}, {"name": null, "address": "a@example.org"}, {"name": null, "address": "b@example.org"}], "cc": [], "bcc": [], "reply_to": [], "subject": null, "date": null, "date_raw": null, "message_id": null, "in_reply_to": null, "references": [], "headers": [{"name": "From", "value": "Éric Lévêque <eric@example.org>"}, {"name": "To", "value": "\"Doe, John\" <john@example.org>, Team: a@example.org, b@example.org;"}], "warnings": ["more than 2 headers in a part: the next ones are ignored (max_headers)"]}"

eml attachments <path> <out_dir>


Description

    Extract the attachments of a mail file, those of the forwarded messages included (their depth is given): {count, saved, attachments, warnings}. The names are made safe, nothing is replaced

Parameters

    path:   The path of the file - String - required
    out_dir:   The directory of the extracted files, created if needed - String - required
admin
if (equal (file exist "tmp/tuto_mail") "1") {file delete "tmp/tuto_mail";}; eml write "{\"from\": \"a@example.org\", \"subject\": \"Report\", \"date\": \"2026-11-03T14:22:05+01:00\", \"message_id\": \"m3@example.org\", \"text\": \"See the file\", \"attachments\": [{\"content_text\": \"a,b\", \"filename\": \"data.csv\"}, {\"content_text\": \"a,b\", \"filename\": \"data.csv\"}, {\"content_text\": \"x\", \"filename\": \"note.txt\"}]}" "tmp/tuto_mail/m.eml" "{\"boundary\": \"BOUNDARY\"}"; -> "[res]" (eml attachments "tmp/tuto_mail/m.eml" "tmp/tuto_mail/out"); file delete "tmp/tuto_mail"; [res]
mentdb
{"count": 3, "saved": 3, "attachments": [{"filename": "data.csv", "content_type": "text/csv", "bytes": 3, "sha256": "1eb7c54d52831bbfe8942af0b1c56b7409523a59ed6ca99c1174fef7eb32c1b5", "inline": false, "content_id": null, "saved_path": "tmp/tuto_mail/out/data.csv", "depth": 0}, {"filename": "data.csv", "content_type": "text/csv", "bytes": 3, "sha256": "1eb7c54d52831bbfe8942af0b1c56b7409523a59ed6ca99c1174fef7eb32c1b5", "inline": false, "content_id": null, "saved_path": "tmp/tuto_mail/out/data_1.csv", "depth": 0}, {"filename": "note.txt", "content_type": "text/plain", "bytes": 1, "sha256": "2d711642b726b04401627ca9fbac32f5c8530fb1903cc4db02258717921a4881", "inline": false, "content_id": null, "saved_path": "tmp/tuto_mail/out/note.txt", "depth": 0}], "warnings": []}

eml attachments <path> <out_dir> <json_params>


Description

    Extract with parameters: inline (true: also the images of the HTML), overwrite (false), max_message_bytes (64 MB, at most 512 MB), max_attachment_bytes (50 MB), max_parts (1000), max_depth (5, forwarded messages), max_text_chars (16 million), max_headers (2000 per part)

Parameters

    path:   The path of the file - String - required
    out_dir:   The directory of the extracted files, created if needed - String - required
    json_params:   The parameters - String - required
admin
if (equal (file exist "tmp/tuto_mail") "1") {file delete "tmp/tuto_mail";}; eml write "{\"from\": \"a@example.org\", \"to\": \"b@example.org\", \"subject\": \"Report\", \"date\": \"2026-11-03T14:22:05+01:00\", \"message_id\": \"m2@example.org\", \"text\": \"See the file\", \"html\": \"<p>See the <b>file</b></p>\", \"attachments\": [{\"content_text\": \"a;b\", \"filename\": \"été.csv\"}]}" "tmp/tuto_mail/m.eml" "{\"boundary\": \"BOUNDARY\"}"; eml attachments "tmp/tuto_mail/m.eml" "tmp/tuto_mail/out"; -> "[res]" (eml attachments "tmp/tuto_mail/m.eml" "tmp/tuto_mail/out" "{\"overwrite\": true}"); file delete "tmp/tuto_mail"; [res]
mentdb
{"count": 1, "saved": 1, "attachments": [{"filename": "été.csv", "content_type": "text/csv", "bytes": 3, "sha256": "5719af18823567701f70e9f302f75d96e574215493286286a57b0a4959672283", "inline": false, "content_id": null, "saved_path": "tmp/tuto_mail/out/été.csv", "depth": 0}], "warnings": []}
Used in use cases (1 recipe)

    Files & archives manager › Read an archived mail and extract its attachments safely
Often used with

    eml parse  ·  eml write  ·  equal  ·  file delete  ·  file exist  ·  file mkdir

eml create <json_message>


Description

    Build an RFC 5322 message as text (pure ASCII, CRLF line breaks): UTF-8 encoded-word headers, folded lines, quoted-printable text when needed, multipart/alternative for text and html, multipart/related for inline images with a content_id, multipart/mixed for the attachments. A line break or a control character in any header value is refused (header injection). Without date and message_id, the current date and a random identifier are used, and the boundary is random

Parameters

    json_message:   The message as a JSON object: from (required), sender, to, cc, bcc, reply_to (each an address, "Name ", {name, address} or an array of them), subject, date (ISO or RFC 5322), message_id, in_reply_to, references, text, html, headers (object or array of {name, value}, not the headers above), attachments: [{path | content_base64 | content_text, filename, content_type, charset, inline, content_id}] - String - required
admin
eml create "{\"from\": {\"name\": \"Éric Lévêque\", \"address\": \"eric@example.org\"}, \"to\": [\"john@example.org\", \"\\"Doe, Jane\\" <jane@example.org>\"], \"subject\": \"Résumé 2026\", \"date\": \"2026-11-03T14:22:05+01:00\", \"message_id\": \"m1@example.org\", \"text\": \"Hello Jane\"}"
mentdb
From: =?UTF-8?B?w4lyaWMgTMOpdsOqcXVl?= <eric@example.org> To: john@example.org, "Doe, Jane" <jane@example.org> Subject: =?UTF-8?B?UsOpc3Vtw6kgMjAyNg==?= Date: Tue, 03 Nov 2026 14:22:05 +0100 Message-ID: <m1@example.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Hello Jane

eml create <json_message> <json_params>


Description

    Build a message with parameters: boundary (a stable boundary, the inner ones add _1, _2), date and message_id (stable values), generate_message_id (true), include_bcc (true: set it to false for a copy where the Bcc must not appear), max_attachment_bytes, max_message_bytes (the sum of the attachments), max_parts. A path of an attachment follows the same rights as file load: never take it from an untrusted JSON

Parameters

    json_message:   The message as a JSON object: from (required), sender, to, cc, bcc, reply_to (each an address, "Name ", {name, address} or an array of them), subject, date (ISO or RFC 5322), message_id, in_reply_to, references, text, html, headers (object or array of {name, value}, not the headers above), attachments: [{path | content_base64 | content_text, filename, content_type, charset, inline, content_id}] - String - required
    json_params:   The parameters - String - required
admin
eml create "{\"from\": \"a@example.org\", \"to\": \"b@example.org\", \"subject\": \"Report\", \"date\": \"2026-11-03T14:22:05+01:00\", \"message_id\": \"m2@example.org\", \"text\": \"See the file\", \"html\": \"<p>See the <b>file</b></p>\", \"attachments\": [{\"content_text\": \"a;b\", \"filename\": \"été.csv\"}]}" "{\"boundary\": \"BOUNDARY\"}"
mentdb
From: a@example.org To: b@example.org Subject: Report Date: Tue, 03 Nov 2026 14:22:05 +0100 Message-ID: <m2@example.org> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="BOUNDARY" --BOUNDARY Content-Type: multipart/alternative; boundary="BOUNDARY_1" --BOUNDARY_1 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit See the file --BOUNDARY_1 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 7bit <p>See the <b>file</b></p> --BOUNDARY_1-- --BOUNDARY Content-Type: text/csv Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename*=UTF-8''%C3%A9t%C3%A9.csv YTti --BOUNDARY--
Header injection refused
admin
eml create "{\"from\": \"a@example.org\", \"subject\": \"Hi\r Bcc: spy@example.org\"}"
mentdb
Sorry, an error appears (the field 'subject' must not contain a line break or a control character (header injection)).

eml write <json_message> <out_path>


Description

    Write the message of eml create to a file: {path, bytes, sha256, warnings}. An existing file is not replaced

Parameters

    json_message:   The message as a JSON object: from (required), sender, to, cc, bcc, reply_to (each an address, "Name ", {name, address} or an array of them), subject, date (ISO or RFC 5322), message_id, in_reply_to, references, text, html, headers (object or array of {name, value}, not the headers above), attachments: [{path | content_base64 | content_text, filename, content_type, charset, inline, content_id}] - String - required
    out_path:   The file to write, with its directories created if needed - String - required
admin
if (equal (file exist "tmp/tuto_mail") "1") {file delete "tmp/tuto_mail";}; eml write "{\"from\": {\"name\": \"Éric Lévêque\", \"address\": \"eric@example.org\"}, \"to\": [\"john@example.org\", \"\\"Doe, Jane\\" <jane@example.org>\"], \"subject\": \"Résumé 2026\", \"date\": \"2026-11-03T14:22:05+01:00\", \"message_id\": \"m1@example.org\", \"text\": \"Hello Jane\"}" "tmp/tuto_mail/m.eml"; -> "[res]" (eml parse "tmp/tuto_mail/m.eml"); file delete "tmp/tuto_mail"; [res]
mentdb
{"from": [{"name": "Éric Lévêque", "address": "eric@example.org"}], "to": [{"name": null, "address": "john@example.org"}, {"name": "Doe, Jane", "address": "jane@example.org"}], "cc": [], "bcc": [], "reply_to": [], "subject": "Résumé 2026", "date": "2026-11-03T14:22:05+01:00", "date_raw": "Tue, 03 Nov 2026 14:22:05 +0100", "message_id": "m1@example.org", "in_reply_to": null, "references": [], "text": "Hello Jane", "html": null, "text_from_html": false, "attachments": [], "forwarded": [], "warnings": []}

eml write <json_message> <out_path> <json_params>


Description

    Write with the parameters of eml create and overwrite (false)

Parameters

    json_message:   The message as a JSON object: from (required), sender, to, cc, bcc, reply_to (each an address, "Name ", {name, address} or an array of them), subject, date (ISO or RFC 5322), message_id, in_reply_to, references, text, html, headers (object or array of {name, value}, not the headers above), attachments: [{path | content_base64 | content_text, filename, content_type, charset, inline, content_id}] - String - required
    out_path:   The file to write, with its directories created if needed - String - required
    json_params:   The parameters - String - required
admin
if (equal (file exist "tmp/tuto_mail") "1") {file delete "tmp/tuto_mail";}; eml write "{\"from\": {\"name\": \"Éric Lévêque\", \"address\": \"eric@example.org\"}, \"to\": [\"john@example.org\", \"\\"Doe, Jane\\" <jane@example.org>\"], \"subject\": \"Résumé 2026\", \"date\": \"2026-11-03T14:22:05+01:00\", \"message_id\": \"m1@example.org\", \"text\": \"Hello Jane\"}" "tmp/tuto_mail/m.eml" "{\"boundary\": \"BOUNDARY\"}"; -> "[res]" (eml write "{\"from\": \"a@example.org\", \"to\": \"b@example.org\", \"subject\": \"Report\", \"date\": \"2026-11-03T14:22:05+01:00\", \"message_id\": \"m2@example.org\", \"text\": \"See the file\", \"html\": \"<p>See the <b>file</b></p>\", \"attachments\": [{\"content_text\": \"a;b\", \"filename\": \"été.csv\"}]}" "tmp/tuto_mail/m.eml" "{\"boundary\": \"BOUNDARY\", \"overwrite\": true}"); file delete "tmp/tuto_mail"; [res]
mentdb
{"path": "tmp/tuto_mail/m.eml", "bytes": 678, "sha256": "8113e9ea960f2dd272b5618b343c2e0027eb1ff60209034dad85f84401c3d599", "warnings": []}
Used in use cases (1 recipe)

    Files & archives manager › Read an archived mail and extract its attachments safely
Often used with

    eml attachments  ·  eml parse  ·  equal  ·  file delete  ·  file exist  ·  file mkdir

msg parse <path>


Description

    Read an Outlook .msg file into the JSON of eml parse (with rtf when the file has no HTML body): recipients with their type, attachments, embedded messages in forwarded

Parameters

    path:   The path of the file - String - required
admin
msg parse "tmp/tuto_mail/note.msg"
mentdb
{"from": [{"name": "Éric Sender", "address": "eric@exemple.fr"}], "to": [{"name": "Alice A", "address": "alice@x.org"}, {"name": "Bob B", "address": "bob@x.org"}], "cc": [{"name": "Carl C", "address": "carl@x.org"}], "bcc": [{"name": "Dan D", "address": "dan@x.org"}], "reply_to": [], "subject": "Sujet été", "date": "2026-11-03T13:22:05Z", "date_raw": null, "message_id": "id123@exemple.fr", "in_reply_to": null, "references": [], "text": "Corps texte é\ ligne 2", "html": "<p>Corps <b>é</b></p>", "text_from_html": false, "attachments": [{"filename": "nom.txt", "content_type": "text/plain", "bytes": 14, "sha256": "a20cf9fe3eb2488f3a5da3cd67270c742540ff5b4912e9321368db63682083c0", "inline": false, "content_id": null, "saved_path": null}, {"filename": "image.png", "content_type": "image/png", "bytes": 4, "sha256": "9f64a747e1b97f131fabb6b447296c9b6f0201e79fb3c5356e6c77e89b6a806a", "inline": true, "content_id": "img1@x", "saved_path": null}], "forwarded": [], "warnings": ["the attachment name '../../évil\\ om.txt' was changed to 'nom.txt'"]}

msg parse <path> <json_params>


Description

    Read a .msg with parameters: save_attachments_to, overwrite, html_to_text, headers, max_message_bytes (64 MB, at most 512 MB), max_attachment_bytes (50 MB), max_parts (1000), max_depth (5, forwarded messages), max_text_chars (16 million), max_headers (2000 per part)

Parameters

    path:   The path of the file - String - required
    json_params:   The parameters - String - required
admin
msg parse "tmp/tuto_mail/note.msg" "{\"save_attachments_to\": \"tmp/tuto_mail/out\", \"html_to_text\": false}"
mentdb
{"from": [{"name": "Éric Sender", "address": "eric@exemple.fr"}], "to": [{"name": "Alice A", "address": "alice@x.org"}, {"name": "Bob B", "address": "bob@x.org"}], "cc": [{"name": "Carl C", "address": "carl@x.org"}], "bcc": [{"name": "Dan D", "address": "dan@x.org"}], "reply_to": [], "subject": "Sujet été", "date": "2026-11-03T13:22:05Z", "date_raw": null, "message_id": "id123@exemple.fr", "in_reply_to": null, "references": [], "text": "Corps texte é\ ligne 2", "html": "<p>Corps <b>é</b></p>", "text_from_html": false, "attachments": [{"filename": "nom.txt", "content_type": "text/plain", "bytes": 14, "sha256": "a20cf9fe3eb2488f3a5da3cd67270c742540ff5b4912e9321368db63682083c0", "inline": false, "content_id": null, "saved_path": "tmp/tuto_mail/out/nom.txt"}, {"filename": "image.png", "content_type": "image/png", "bytes": 4, "sha256": "9f64a747e1b97f131fabb6b447296c9b6f0201e79fb3c5356e6c77e89b6a806a", "inline": true, "content_id": "img1@x", "saved_path": "tmp/tuto_mail/out/image.png"}], "forwarded": [], "warnings": ["the attachment name '../../évil\\ om.txt' was changed to 'nom.txt'"]}

msg to_eml <path> <out_path>


Description

    Convert an Outlook .msg to an .eml file: {path, bytes, sha256, warnings}. Bodies, attachments and embedded messages are kept. The warnings say what is lost: an internal Exchange address, a missing sender or date, an RTF body. The transport headers (Received...) are not copied

Parameters

    path:   The path of the file - String - required
    out_path:   The file to write, with its directories created if needed - String - required
admin
msg to_eml "tmp/tuto_mail/note.msg" "tmp/tuto_mail/note.eml"
mentdb
{"path": "tmp/tuto_mail/note.eml", "bytes": 1533, "sha256": "4193193f9e448d81d9b4c19bf11f866424b215e74aea43fdcf6994d250f653c3", "warnings": ["the attachment name '../../évil\\ om.txt' was changed to 'nom.txt'"]}

msg to_eml <path> <out_path> <json_params>


Description

    Convert with parameters: overwrite (false), include_bcc (true), boundary, max_message_bytes, max_attachment_bytes, max_parts, max_depth

Parameters

    path:   The path of the file - String - required
    out_path:   The file to write, with its directories created if needed - String - required
    json_params:   The parameters - String - required
admin
msg to_eml "tmp/tuto_mail/note.msg" "tmp/tuto_mail/note.eml" "{\"overwrite\": true, \"boundary\": \"BOUNDARY\", \"include_bcc\": false}"
mentdb
{"path": "tmp/tuto_mail/note.eml", "bytes": 1113, "sha256": "f6ea8bd9c178db299d366fcf0d902cae7550c535883631bccb9d058a21556871", "warnings": ["the attachment name '../../évil\\ om.txt' was changed to 'nom.txt'"]}