LinuxCommandLibrary

mail

sends and reads email

TLDR

Send email

$ mail -s "[Subject]" [recipient@example.com]
copy
Send with body
$ echo "[message]" | mail -s "[Subject]" [recipient@example.com]
copy
Send file contents
$ mail -s "[Subject]" [recipient@example.com] < [message.txt]
copy
Send with attachment
$ mail -s "[Subject]" -A [file.pdf] [recipient@example.com]
copy
Read mail
$ mail
copy
Check specific mailbox
$ mail -f [/var/mail/user]
copy

SYNOPSIS

mail [options] [recipients]

DESCRIPTION

mail sends and reads email. It's a basic command-line mail user agent.
The tool can send quick emails from scripts. It reads mail from local mailboxes.

PARAMETERS

RECIPIENTS

Email addresses.
-s SUBJECT
Email subject.
-A FILE
Attach file.
-c ADDR
CC recipients.
-b ADDR
BCC recipients.
-f FILE
Read from mailbox.
--help
Display help information.

CAVEATS

Requires MTA configured. Various implementations. May need mailutils package.

HISTORY

mail dates back to early Unix systems, providing basic email functionality for users and scripts.

SEE ALSO

mailx(1), sendmail(8), mutt(1)

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard