Mailx command in linux example

The mailx command in Linux is a simple email client that allows you to send and receive emails. Here are some examples of how to use it:

Sending an email

To send an email using mailx, you can use the following command:

mailx -s "Subject" [email protected]

This will open a text editor where you can type the body of the email. When you're done, save the file and exit the editor. The email will be sent to the recipient.

For example:

mailx -s "Hello World" [email protected]

This will send an email with the subject "Hello World" to the recipient [email protected].

Sending an email with attachments

To send an email with attachments using mailx, you can use the -a option followed by the name of the attachment file. For example:

mailx -s "Hello World" -a attachment.txt [email protected]

This will send an email with the subject "Hello World" and attach the file attachment.txt to the email.

Receiving emails

To receive emails using mailx, you can use the following command:

mailx

This will display a list of emails in your inbox. You can then use the d command to delete an email, r command to reply to an email, or f command to forward an email.

For example:

mailx

This will display a list of emails in your inbox. You can then use the d command to delete an email, for example:

d 1

This will delete the first email in the list.

Other options

Here are some other options you can use with mailx:

These are just a few examples of how to use the mailx command in Linux. You can use the man command to learn more about the options and syntax of the mailx command.