LinuxCommandLibrary

mailx

enhanced mail command

TLDR

Send email

$ mailx -s "[Subject]" [recipient@example.com]
copy
Send with body
$ echo "[message]" | mailx -s "[Subject]" [recipient@example.com]
copy
Send file
$ mailx -s "[Subject]" [recipient@example.com] < [message.txt]
copy
Send with attachment
$ mailx -s "[Subject]" -a [file.pdf] [recipient@example.com]
copy
Read mail
$ mailx
copy
Use SMTP server
$ mailx -S smtp=[smtp://mail.example.com] -s "[Subject]" [recipient@example.com]
copy

SYNOPSIS

mailx [options] [recipients]

DESCRIPTION

mailx is an enhanced mail command. It supports SMTP, attachments, and more features than basic mail.
The tool is POSIX-compatible with extensions. It handles both sending and reading email.

PARAMETERS

RECIPIENTS

Email addresses.
-s SUBJECT
Email subject.
-a FILE
Attach file.
-c ADDR
CC recipients.
-S VAR=VALUE
Set variable.
-f FILE
Read from mailbox.
--help
Display help information.

CAVEATS

Multiple implementations exist. SMTP config varies. May need s-nail or heirloom-mailx.

HISTORY

mailx evolved from the original Unix mail command, adding features like MIME support and SMTP.

SEE ALSO

mail(1), mutt(1), sendmail(8)

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard