relman CLI: Mail
← Back to the relman CLI command overview
list mailfolder (aliases: mailfolders, mf)
Fetches the id and name of every mail folder owned by your own account (resolved from the client certificate). Unlike every other “list” command, this one takes no organization/project-group/project token, since mail folders do not sit anywhere under that tree.
import mail <mailfolder-token> <path>
Imports one local .eml file, or – if <path> is a directory – every .eml file directly inside it (not recursive), into the folder identified by <mailfolder-token>. Each file’s MD5 (matching the hash the web UI’s own drag-and-drop importer computes client-side) and filename are sent as query-string parameters, its raw bytes as the request body – the import is delegated to the exact same importer the web UI itself uses, so a file already imported (matching hash) or one whose sender/recipients have no mail-permission on the target folder is reported the same way for either caller.
Exit code is 0 if every file’s HTTP request succeeded, regardless of whether the server logically imported it or not (see the per-file “imported” field printed for each); 1 if any request itself failed; 2 on a usage error.
Examples
1. Listing your mail folders
Global flags omitted below – see Utility & global flags. No org/project chain needed here – a mail folder belongs to your account directly.
$ relman list mailfolder
- id: mf-3xQa9K
name: Support Inbox
- id: mf-Ht72Wm
name: Archive
Edge case: this always resolves against your own account (from the client certificate) – there is no way to list another account’s mail folders with this command.
2. Importing an .eml file
$ relman import mail mf-3xQa9K ./inbox/ticket-4821.eml
Importing ./inbox/ticket-4821.eml ...
imported: true
Edge case: pointing <path> at a directory instead of a file imports every .eml file directly inside it – not recursively into subdirectories.
3. Importing the same file twice
$ relman import mail mf-3xQa9K ./inbox/ticket-4821.eml
Importing ./inbox/ticket-4821.eml ...
imported: false
Edge case: the exit code is still 0 here – the HTTP request itself succeeded, the server just logically rejected it (matching MD5 hash already on file, or no mail-permission for the sender/recipients on that folder). Always check the printed imported field, not just the exit code, when scripting bulk imports.