If I ask you how to send an email, what would you say? You will say go to gmail or yahoo mail and send the email. But, do you know that you can send emails using your Linux command line? Yes! you heard me right.
We can do this by using the mail command. In other words, it is a simple email client that gives you the basic email facilities. Moreover, this will allow you to send and read emails in your inbox. In this guide, I will show you how to do that.
Step 01 : Installation
Firstly, you have install it by using the following command
#sudo apt install mailutils
Step 02: Sending a simple mail
Run the following command to send a simple mail. Moreover, you can set the subject of the mail and the receiver’s address in the command
#mail -s “<subject>” <Email_address>
Once you hit enter, you will be asked to add the CC address and type in the message. After that, the mail command would send the message.
Step 03 : Setting the message body
You can also set the message body in just one line of command
#mail -s “<subject>” <Email_address> <<< <message>
Step 04 : Get the input from a file
Similarly, you can direct the mail command to get the message from a file
#mail -s “<subject>” <Email_address> < <location>
Step 05 : Specify CC and BCC recipients
Use the below command to Specify CC and BCC recipients in one line of command
#mail -s “<subject>” <Email_address> -c <CC_address> -b <BCC_address>
Step 06 : Send to a local user
You can also send a mail to a local system user
#mail -s “<subject>” <username>
You could also append “@hostname” to the username. Therefore, the hostname should be the hostname of the current system.
#mail -s “<subject>” <username@hostname>
Step 07 : View a detailed output
If you need to view a detailed output, use the -v option
#mail -v -s “<subject>” <Email_address>
Step 08 : Check your inbox
You can also view your inbox. For that, you simply have to run the mail command.
In conclusion, mail command is a useful tool that we can use to handle our emails. Therefore, you can practice using this if you need to get rid of using the email clients when using the command line. Moreover, you can check this article to see another tool that you can use for this task.
Latest posts by Ruwantha Nissanka (see all)
- 4 ways to hide your identity using linux - January 18, 2021
- How To Install Kali Linux in Virtualbox - December 31, 2020
- Kali Linux : The OS That Hackers Use - December 31, 2020
- How to monitor user activity in Linux with Acct - December 30, 2020
- Debsecan : You will not miss another security update - December 28, 2020