Skip to main content

The command operates on the user's mailbox if no argument is given. To send an email the message body is built from standard input.

# To send a typed email message. The commandline below continues after pressing Enter key. Input CC email-id (optional) press Enter key. Input message text (can be multi-line). Press "Ctrl-D" key to complete the message text:
mail --subject=<"subject line"> <>

# To send an email that contains file content:
mail --subject=<"$HOSTNAME filename.txt"> <> < <path/to/filename.txt>

# To send a tar.gz file as an attachment:
tar cvzf - <path/to/directory1 path/to/directory2> | uuencode <data.tar.gz> | mail --subject=<"subject line"> <>