How to make use of mail command in Linux

2

Mail is the fastest method of speaking messages for your family members, there are other electronic mail shopper servers that permit customers to ship emails, but even so this, Linux via default supplies the function of sending an electronic mail the use of the “mail” command thru its terminal. We can write the topic, message in conjunction with the e-mail cope with of the recipient and ship it via simply executing a unmarried command.

There are other programs wherein we will be able to set up the mail command, those programs are mentioned on this write-up in addition to the usage of the mail command may be defined intimately.

Installation of mail programs for various distributions of Linux

Mail programs will also be put in in numerous distributions of Linux the use of the below-mentioned instructions.

For CentOS/Redhat:

For Fedora/ RHEL:

For Debian/ Ubuntu/ Linux Mint:

$ sudo apt set up mailutils

Installation of Mail package deal in Ubuntu

We are going to put in the mail package deal in Ubuntu the use of the mailutils package deal:

$ sudo apt set up mailutils -y

It will show the 4 choices of the postfix with its main points, learn all of the choices, and click on “Ok” after deciding which possibility you need to select, as we made up our minds to head with “Internet site”:

how to make use of mail command in linux How to make use of mail command in Linux 1640295993 524 How to use mail command in Linux

Choose the “Internet Site” after which press “Ok”:

how to make use of mail command in linux How to make use of mail command in Linux 1640295993 840 How to use mail command in Linux

Choose the area identify, we selected “linuxhint”, you’ll be able to make a choice of your individual selection, and click on at the “Ok” button to continue:

how to make use of mail command in linux How to make use of mail command in Linux 1640295994 933 How to use mail command in Linux

The mailutils is effectively put in.

How to make use of the mail command in Linux

The mail command in Linux is used to ship emails to other other people for speaking some messages, to make use of the mail command, we have now put in the mailutils, now the overall syntax of the use of the mail command will likely be:

$ mail -s “subject” [recipient-email-address]
CC [you can skip it by pressing the ENTER key]
Type the textual content you need to ship>
[Press CTRL + D]

Use the clause of mail to finish the mail, the sort “-s” to specify the topic, kind the recipient electronic mail cope with, press the ENTER key, it’s going to ask for the CC (carbon reproduction) give it or skip it via urgent the ENTER key, kind the message, you need to keep up a correspondence and in any case press CTRL+D to ship the message.

For the easier figuring out, we ship a message the use of an electronic mail cope with, [email protected], we can use the command:

$ mail -s “casual mail” maadiim.mm@gmail.com

And when the “cc” will likely be requested, we can skip it via urgent the ENTER key after which kind the message:

how to make use of mail command in linux How to make use of mail command in Linux 1640295994 0 How to use mail command in Linux

On urgent the CTRL+D, the mail will likely be despatched effectively, we will be able to additionally ship the similar mail the use of the one command:

$ mail -s “casual mail” maadiim.mm@gmail.com ‘How are you?’

how to make use of mail command in linux How to make use of mail command in Linux 1640295994 405 How to use mail command in Linux

Or the wrong way of sending an electronic mail the use of a unmarried command:

$ echo “How are you?” | mail -s “casual mail” maadiim.mm@gmail.com

how to make use of mail command in linux How to make use of mail command in Linux 1640295994 357 How to use mail command in Linux

Sometimes, we need to ship the mail to more than one customers, if that’s the case, use the next syntax:

$ mail -s “casual mail” maadiim.mm@gmail.com , hammadzahid@hotmail.com ‘How are you?’

how to make use of mail command in linux How to make use of mail command in Linux 1640295994 613 How to use mail command in Linux

If we need to connect some document with the e-mail cope with, use the “-a” flag in conjunction with the mail command like we have now a png document with identify, index.png, we connect it with the mail the use of the command:

$ mail -s “casual mail” maadiim.mm@gmail.com , hammadzahid@hotmail.com ‘How are you? I’m sending you a picture’ -A /house/hammad/Downloads/index.png

how to make use of mail command in linux How to make use of mail command in Linux 1640295994 836 How to use mail command in Linux

If we have now a message in a textual content document and we need to ship the mail from the textual content document, execute the next command:

$ mail -s “casual mail” maadiim.mm@gmail.com /house/hammad/mymail.txt

how to make use of mail command in linux How to make use of mail command in Linux 1640295994 458 How to use mail command in Linux

To learn the mails, use the command of “mail”:

how to make use of mail command in linux How to make use of mail command in Linux 1640295994 724 How to use mail command in Linux

In the output, we will be able to see there are 13 mails, to open any mail, we will be able to write its index quantity and press the ENTER key, for instance, if we need to open the 7th mail, we can kind “7” and press the ENTER key:

how to make use of mail command in linux How to make use of mail command in Linux 1640295994 441 How to use mail command in Linux

The mail and its element had been opened:

how to make use of mail command in linux How to make use of mail command in Linux 1640295994 602 How to use mail command in Linux

Similarly, to delete the emails from 4 – 15, simply kind “d 4 15” and press the ENTER key:

how to make use of mail command in linux How to make use of mail command in Linux 1640295994 672 How to use mail command in Linux

To verify the deletion of the mails, run the command of mail once more:

how to make use of mail command in linux How to make use of mail command in Linux 1640295994 519 How to use mail command in Linux

We can follow that the required emails had been deleted from the inbox, on this method, we will be able to organize the mail inbox as neatly.

Conclusion

In Linux, the mail command is a command-line software this is used to ship and organize the emails from the command line. The mail command isn’t used to ship emails simplest but in addition to view and obtain emails from the recipients. In this write-up, we have now mentioned the mail command and its set up instructions in numerous distributions of Linux. We additionally mentioned the use of the mail command intimately in Debian and Ubuntu-based Linux distributions.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More