Mail command on linux
The mail
command on Linux!
The mail
command is a simple command-line email client that allows you to send and receive email messages. Here are some basic usage examples:
Sending an email
To send an email using the mail
command, you can use the following syntax:
mail -s "Subject" [email protected]
Replace Subject
with the subject of your email and [email protected]
with the email address of the recipient.
You will then be prompted to enter the email body. You can type your message, and then press Ctrl+D
to send the email.
Receiving email
To receive email using the mail
command, you can use the following syntax:
mail
This will display your email inbox, and you can use the following commands to manage your emails:
h
orhelp
: Display help informationl
orlist
: List all emails in your inboxr
orread
: Read a specific emaild
ordelete
: Delete a specific emailq
orquit
: Quit the email client
Example usage
Here's an example of how you can use the mail
command to send and receive email:
$ mail -s "Hello World" [email protected]
Subject: Hello World
Hello,
This is a test email.
Press Ctrl+D to send the email.
$ mail
Mail version 12.5 6/6/93
Type? for help
"Mail" is on
Mailbox is locked
>l
1 [email protected] (1 message)
>1
From [email protected] Mon Jun 13 14:30:00 2023
Subject: Hello World
Hello,
This is a test email.
>q
In this example, we first use the mail
command to send an email to [email protected]
with the subject "Hello World". We then use the mail
command again to receive email, and list all emails in our inbox using the l
command. We then read the first email using the 1
command, and quit the email client using the q
command.
Note: The mail
command is a simple email client, and it may not support all the features you're used to in a modern email client like Gmail or Outlook. However, it's still a useful tool for sending and receiving email from the command line.