![mail command in linux mail command in linux](https://i.ytimg.com/vi/YKXq9rCFM-U/maxresdefault.jpg)
You can also use ‘|’ pipe to pass the message body to mailx command as shown below. It displays EOT and exists the message body and sends the mail. Then enter the message body and click on Ctrl+D to complete the message. Just log in to the Unix console and run the below command and hit enter.
![mail command in linux mail command in linux](https://1.bp.blogspot.com/-0aR-_xbPiO0/X19MBItfDRI/AAAAAAAAEs4/GfWnBANqWgQAKGIcuRVYdw0_53IQQ5magCLcBGAsYHQ/s1600/tmpmail.png)
Now, let’s explore some practical options of mailx command with examples. The mailx command supports good options which help you to send an email with and without attachment. It just exits the command without saving any changes done to the mailbox. The quit option remembers message status and moves read emails to mbox folder, permanently deletes deleted message while the same is not the case with the exit. You can exit mailx command using either the quit or exit option. If you use exit option, as mentioned below nothing happens on the message as mailx discard all the changes are done on the mailbox. The message gets permanently deleted from your mailbox. Remember, once you delete the message and exit the mailbox with the quit command. Specify the number of the message with this option. d 1-5Ĭhanged your mind and now want to recover the message, just use u option to undelete the deleted message. This deletes the message with sequence number 1.ĭelete multiple message e.g 1 and 2 d 1 2ĭelete multiple messages by specifying the range. mailx allows you to delete one message, multiple messages or you can even specify the range of the message.
![mail command in linux mail command in linux](https://www.tecmint.com/wp-content/uploads/2013/10/Mutt-1.png)
Use the d option followed by the number of messages to delete the message. If you omit the number, it will reply to the current message. Just type r with message number to reply to that message. Type h on the command to list all the headers of the message. Just type the sequence of the email message e.g 1, 2 on the terminal to read the respective email.Īs soon as you read emails, the status of the message changes from New to Read.
![mail command in linux mail command in linux](https://all-learning.com/wp-content/uploads/2019/02/test-mails.png)
Mailx with -f option allows you to open your personal mailbox, other user’s system mailbox if you have access as shown below. There is a list of all emails with the sequence number, status, date received, size and subject. Mailx command by default opens the current user’s system mailbox (/var/mail/), so just Open the Unix/Linux terminal and type mailxwithout any parameters on the command prompt to read emails.įirst, you get a summary like a User Mailbox, Total Messages, Total new and unread email, etc. Covering all aspects of this command is beyond the scope of this article.Īll the examples mentioned below are tested with GNU mailx on Ubuntu 18.04 and Ubuntu 20.04 Linux Distro. We are going to cover the basics of mailx for practical purposes. It has hosts of features even though it is command-based. You can use mailx command to read, write, reply, delete messages. Just use –help option to quickly get help. Those who are interested to learn more about mailx utility, visit mailutilis documentation page or run man command as shown below. Note:- All parameters to this command are optional. This displays details of delivery on the user’s terminal -c – send carbon copies to list of users.-b – send blind carbon copies to list of users.-a – attach the given filename to message.Mention it in double-quotes if it contains space
MAIL COMMAND IN LINUX HOW TO
We will see how to read, send and delete emails using the mailx unility.
MAIL COMMAND IN LINUX INSTALL
You can use this article which should help you to install mailx. Mailx should not be availalble on your system unless you install it.