mail Cheat Sheet

The UNIX mail command is a fundamental utility on Unix-like operating systems used to send and receive electronic mail directly from the command line. 

 It functions as a Mail User Agent (MUA) that allows users to manage their mailbox, compose messages, and interact with recipients without a graphical interface. 

Start / Exit

mail open mailbox
q quit and SAVE changes
x exit WITHOUT saving

Reading Mail

Enter next message
p print current message
n next message
5 jump to message 5

Deleting Mail

d 1 2 3 delete specific messages
d 1-10 delete range
d * delete ALL messages
d . delete current message
d .-5 current + previous 5

Search and Delete

/word search messages
d /word delete matches

Examples:

d /cron
d /root

Smart Selectors

d :r delete all read
d :n delete all new
d :u delete all unread

Message Management

h show headers
z next page
z- previous page

Sending / Replying

r reply
R reply to all
m user send mail

Saving Messages

s 5 file save message 5
s 1-10 mbox save multiple

Undelete (before quitting)

u 3 undelete message 3
u 1-5 undelete range

Quick Workflows

Delete first 50 + read mail:

mail
d 1-50
d :r
q

Delete everything:

mail
d *
q

Delete by keyword:

mail
d /spam
q

Notes

  • Changes only apply after q
  • Use x to cancel all changes
  • You can combine multiple delete commands before quitting