HiveBrain v1.2.0
Get Started
← Back to all entries
snippetbashTip

mail — Operate on the user's mailbox. To send an email the message body is built from `stdin`. More informa

Submitted by: @import:tldr-pages··
0
Viewed 0 times
operatethemailboxcommandsendmailcliuser

Problem

How to use the mail command: Operate on the user's mailbox. To send an email the message body is built from stdin. More information: <https://manned.org/mail>.

Solution

mail — Operate on the user's mailbox. To send an email the message body is built from stdin. More information: <https://manned.org/mail>.

Open an interactive prompt to check personal mail:
mail


Send a typed email message with optional CC. The command-line below continues after pressing <Enter>. Input message text (can be multiline). Press <Ctrl d> to complete the message text:
mail --subject "{{subject line}}" {{to_user@example.com}} --cc "{{cc_email_address}}"


Send an email that contains file content:
mail < {{path/to/file.txt}} --subject "{{$HOSTNAME filename.txt}}" {{to_user@example.com}}


Send a .tar.gz file as an attachment:
tar cvzf - {{path/to/directory1 path/to/directory2}} | uuencode {{data.tar.gz}} | mail --subject "{{subject_line}}" {{to_user@example.com}}


Display help:
mail {{[-h|--help]}}

Code Snippets

Open an interactive prompt to check personal mail

mail

Send a typed email message with optional CC. The command-line below continues after pressing `<Enter>`. Input message text (can be multiline). Press `<Ctrl d>` to complete the message text

mail --subject "{{subject line}}" {{to_user@example.com}} --cc "{{cc_email_address}}"

Send an email that contains file content

mail < {{path/to/file.txt}} --subject "{{$HOSTNAME filename.txt}}" {{to_user@example.com}}

Send a `.tar.gz` file as an attachment

tar cvzf - {{path/to/directory1 path/to/directory2}} | uuencode {{data.tar.gz}} | mail --subject "{{subject_line}}" {{to_user@example.com}}

Display help

mail {{[-h|--help]}}

Context

tldr-pages: common/mail

Revisions (0)

No revisions yet.