Linux serverNETWORK ADMINISTRATIONSsmtp server liux

How to Use Mail Unix Command

The Main UNIX command in Linux allows you to view and send emails. Mails through this command can be sent from other accounts as well.

Don’t forget to check out our site for more free how-to videos! – our feed – join us on facebook – our group in Google+

In this tutorial we will show you how to use the mail unix command. This command allows you to send and read emails. You can send it through guest accounts, other accounts or your own that is the local user account.
To understand more about the unix mail commands follow the tutorial steps given below.

Step 1 — Enter the mail command

With the mail command, you can send and read the emails in your inbox. You have to basically work with the users attribute over here. If specified, you can send the mail to that particular user, and if not you can read your emails. Let’s look at an example over here.
First of all let’s type the mail command and hit enter. This will check the mail of the current user, which is the root.

Step 2 — Check mail of a particular user

What if you want to check the mail of a particular user? For that we will use “-f” flag followed by the name of the user.

Step 3 — Check mail of guest accounts

Similarly, you can use the “-f” flag to check the emails for the guest accounts even.

Step 4 — Send mail to local user account

If you want to send a mail to your local user account, type “mail user@Ubuntu” and hit enter.
With that done, it will ask who you want to Cc the message to. You can leave this blank by simply pressing the enter key. Next, you will be asked to write the Subject for the email. With that done, you will be required to type the actual message you want to send out. Remember to press the CTRL+D key at the end, once you have typed the message.
With that done, the message will be sent via the mail unix command line only.

Step 5– Check if email is received

Now let’s check if the user has received the email or not. For that, we will use the mail command with the -f flag.
And over here, you can see that 1 message is present in the inbox.
And that’s it, from the above steps you can understand the function of the unix mail commands in Linux.



linux smtp client

Leave a Reply

Your email address will not be published. Required fields are marked *