Mailx send mail

A blast from the past!

mailx is a command-line email client that allows you to send and receive email messages. Here's a basic syntax to send an email using mailx:

Simple Email

mailx -s "Subject" [email protected]

This will open a text editor where you can compose your email message. When you're done, save the file and exit the editor. The email will be sent to the specified recipient.

Example with Body

mailx -s "Hello World" [email protected] << EOF
This is the body of the email.
EOF

In this example, the << EOF syntax is used to specify the end of the email body. You can type your email message, and when you're done, type EOF to indicate the end of the message.

Example with Attachments

mailx -s "Hello World" [email protected] << EOF
This is the body of the email.
EOF
mailx -a attachment.txt [email protected]

In this example, the first command composes the email message, and the second command attaches a file named attachment.txt to the email.

Options

Here are some common options you can use with mailx:

Note: The mailx command is not as feature-rich as modern email clients like Gmail or Outlook. It's primarily used for simple email tasks and is often used in scripting and automation scenarios.