mailutil(1)

πŸ’Œ mailutil β€” the mail utility program (yes bestie, it's mailutil(1))

okay so. sit down. hydrate. because this little icon right here does a LOT and it's about to become your whole personality.


✨ NAME ✨

mailutil β€” mail utility program. that's it. that's the name. she does mail, she's a utility, she's a program. πŸ’…


🌸 SYNTAX 🌸

mailutil command [switches] [arguments]

All commands accept the -d, -v, and -u switches in addition to any
command-specific switches.

mailutil check [MAILBOX]

mailutil create MAILBOX

mailutil delete MAILBOX

mailutil rename SOURCE DESTINATION

mailutil copy [-rw] [-kw] [-ig] SOURCE DESTINATION

mailutil move [-rw] [-kw] [-ig] SOURCE DESTINATION

mailutil append [-rw] [-kw] [-ig] SOURCE DESTINATION

mailutil appenddelete [-rw] [-kw] [-ig] SOURCE DESTINATION

mailutil prune MAILBOX CRITERIA

mailutil transfer [-m mode] [-rw] [-kw] [-ig] SOURCE DESTINATION

so the shape of it is literally mailutil command [switches] [arguments] β€” command first, then switches, then args. and listen: every single command also accepts -d, -v, and -u on top of whatever command-specific switches it has. universal besties. periodt.


πŸ¦‹ DESCRIPTION πŸ¦‹

mailutil is the glow-up that replaces the old crew: chkmail, imapcopy, imapmove, imapxfer, mbxcopy, mbxcreat, and mbxcvt. seven little programs, one main character now. we love a consolidation arc. 😌


🌈 mailutil check

determines whether new mail exists in the given mailbox β€” and if you don't give one, the default is INBOX, obviously.

the number of new messages is defined as the number of messages that have "Recent" status set. that's the definition, no cap.

if the mailbox has no new messages, mailutil check will indicate that no new mail is present. otherwise? it reports the number of new messages. and either way, it also tells you the canonical form of the name of the mailbox. so you always get that little bonus, king behavior. πŸ‘‘


πŸŽ€ mailutil create

creates a new mailbox with the given name. and the rule is: the mailbox name must not already exist. don't try it. it's not gonna work.

you can create a mailbox in a particular format by prefixing the name with #driver. followed by the format name and a / character. for example, this command

mailutil create #driver.mbx/junkmail

will create a new mailbox named "junkmail" in mbx format. iconic. πŸ’–


πŸ’€ mailutil delete

deletes an existing mailbox with the given name. that's it. that's the whole thing. bye bestie. πŸ‘‹


🧚 mailutil rename

renames an existing mailbox to a new name β€” and the new name must not already exist.

but here's the catch, and it's a real one: this only works if the old and new names are in the same mail store. same store or it's not happening.

a more general means to rename a mailbox is to do a mailutil copy of the old name to the new name, followed by a mailutil delete of the old name. two steps, more power, lowkey the move.


πŸ“ mailutil copy

creates a new mailbox and copies messages from the old mailbox to the new mailbox. and just like with mailutil create, you can specify a mailbox format with the new mailbox. for example, this command

mailutil copy INBOX #driver.mbx/INBOX

will copy messages from your existing INBOX to an mbx-format INBOX. yes bestie, upgrading your whole filing system. ✨


πŸ”₯ mailutil move

similar to mailutil copy, but in addition it will also remove (delete and expunge) the messages from the old mailbox after copying them to the new mailbox. so it's copy, but make it ✨dramatic✨. gone. expunged. no forwarding address.


πŸ’… mailutil append and mailutil appenddelete

these are similar to mailutil copy and mailutil move respectively β€” except that they do not create the destination mailbox. so the destination better already exist, or you're gonna have a bad time. πŸ™ˆ


πŸ¦„ mailutil prune

prunes the mailbox of messages which match certain criteria, which are in the form of IMAP2 (RFC 1176) SEARCH arguments.

for example, this command

mailutil prune INBOX "before 1-jan-2004"

will delete and expunge all messages written before January 1, 2004. spring cleaning but make it ruthless. 🌸

not me being the bearer of bad news: mailutil implements pruning by deleting the matching messages, and then expunging the mailbox. consequently, mailutil will also expunge any messages which were deleted at the time of the pruning. so if you had stuff already sitting in the deleted-but-not-expunged pile, it's going with them. fair warning. 😭

🌟 mailutil transfer

copies an entire hierarchy of mailboxes from the named source to the named destination. mailboxes are created on the destination as needed. any error in copying messages will cause the transfer to stop. full stop. no skipping ahead.

normally, any error in creation will cause the transfer to stop too. however, if -m MODE or -merge MODE is specified, a merging transfer is performed. the MODE argument indicates the type of merge:

  • -m[erge] prompt β€” indicates that the user should be asked for an alternative name to create. if creating the new name fails, the user will be asked again. and again. and again. it's giving "we'll keep asking until you get it right". 🫢
  • -m[erge] append β€” indicates that it's alright to copy the messages into an existing mailbox with that name. if the mailbox does not exist, the user will be prompted for an alternative name.
  • -m[erge] suffix=XXXX β€” where XXXX is any string, indicates that an alternative name should be built by appending the given suffix to the name. if that alternative name can't be created, then the user will be prompted for an alternative name.

so how does the hierarchy math work? the source hierarchy consists of all mailboxes which start with the given source name. with the exception of a remote system specification (within "{}" braces), the source name is used as the name of the destination. the destination hierarchy is a prefix applied to any new names being created.

for example,

mailutil transfer foo bar

will copy all mailboxes with names beginning with "foo" to names beginning with "bar" (hence "foobar" will be copied to "barfoobar"). yes, the string math is doing exactly what you think it's doing. πŸ’€

similarly,

mailutil transfer "{imap.foo.com}" "{imap.bar.com}old/"

will copy all mailboxes from the imap.foo.com IMAP server to equivalent names starting with "old/" on the imap.bar.com IMAP server. server glow-up. ✨


πŸ’– FLAGS πŸ’–

  • -d, -debug β€” prints full debugging telemetry including protocol operations. everything. all of it. the whole feed.
  • -v, -verbose β€” prints verbose (non-error) telemetry. chattier, but not the full firehose.
  • -u USERID, -user USERID β€” attempts to become the indicated user. this is for the benefit of system administrators who want to do mailutil operations on a userid that does not normally have shell access. king shit only, honestly. πŸ‘‘
  • -rw, -rwcopy β€” causes the source mailbox to be open in readwrite mode rather than readonly mode. normally, mailutil tries to use readonly mode to avoid altering any flags in the source mailbox, but some mailbox types, e.g. POP3, can't be open in readonly mode. so for those, this is the way.
  • -kw, -kwcopy β€” causes the keywords of the source mailbox to be created in the destination mailbox. normally, mailutil does not create keywords in the destination mailbox, so only those keywords that are already defined in the destination mailbox will be preserved. note that some IMAP servers may automatically create keywords, so this flag may not be necessary. lowkey optional, highkey handy. πŸŽ€
  • -ig, -ignore β€” causes the keywords of the source mailbox to be ignored completely and no attempt is made to copy them to the destination mailbox. not a single attempt. 🚫
the exclusivity tea: -ig[nore] and -kw[copy] are mutually exclusive. pick a lane bestie, you can't have both. πŸ’…

🌸 ARGUMENTS 🌸

the arguments are standard c-client mailbox names. a variety of mailbox name formats and types of mailboxes are supported by c-client. here are the most common forms of names, with what they mean:

  • INBOX β€” primary incoming mail folder on the local system
  • archive/tx-project β€” mail folder named "tx-project" in "archive" subdirectory of local filesystem home directory
  • {imapserver.foo.com}INBOX β€” primary incoming mail folder on IMAP server system "imapserver.foo.com"
  • {imapserver.foo.com}archive/tx-project β€” mail folder named "tx-project" in "archive" subdirectory on IMAP server system "imapserver.foo.com"
  • #news.comp.mail.misc β€” newsgroup "comp.mail.misc" on local filesystem
  • {newserver.foo.com/nntp}comp.mail.misc β€” newsgroup "comp.mail.misc" on NNTP server system "newserver.foo.com"
  • {popserver.foo.com/pop3} β€” (the original gives this one no meaning text, she just stands there. iconic in her own way. 🫢)

see your system manager for more information about the types of mailboxes which are available on your system. they know things. ask them. ✨


🚧 RESTRICTIONS 🚧

  • you must surround a {host}mailbox argument with quotation marks if you run mailutil from csh(1) or another shell for which braces have special meaning. quote it or suffer.
  • you must surround a #driver.format/mailbox argument with quotation marks if you run mailutil from a shell in which "#" is the comment character. same energy. quote it. 😀

πŸ‘‘ AUTHOR πŸ‘‘

Mark Crispin, MRC@Washington.EDU. the legend herself. 🫑


and that's the whole page, bestie!! this one's from the General Commands Manual, dated March 3, 2008 β€” vintage, but she still eats. go forth and mailutil responsibly. mwah. πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from