How to delete mail in mail command in ubuntu terminal
To delete a mail using the mail
command in Ubuntu terminal, you can use the following syntax:
mail -s "delete" <message_number>
Here:
mail
is the command to access your email inbox.-s
is the option to specify the action to take. In this case,delete
is the action to delete the message.<message_number>
is the number of the message you want to delete. You can find the message number by using themail
command without any options, which will display a list of your emails with their corresponding numbers.
For example, if you want to delete the 5th message in your inbox, you would use the following command:
mail -s "delete" 5
If you want to delete multiple messages, you can specify a range of message numbers. For example, to delete messages 3 to 5, you would use:
mail -s "delete" 3-5
Note that the mail
command only deletes messages from the current mailbox. If you want to delete messages from a specific mailbox, you need to specify the mailbox name along with the message number. For example:
mail -s "delete" <mailbox_name>/3
Replace <mailbox_name>
with the name of the mailbox you want to delete messages from.
Also, note that the mail
command does not permanently delete messages. Instead, it moves them to the "Trash" folder. If you want to permanently delete messages, you can use the rm
command to delete the message files from the mailbox directory. For example:
rm /var/mail/<username>/message.1234
Replace <username>
with your username and message.1234
with the name of the message file you want to delete.