Linux mail from
The classic mail
command!
In Linux, the mail
command is a simple way to send and receive email messages. Here's a brief overview of how to use it:
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 body of the email. You can type in the 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 a list of your email messages. You can then use the following commands to manage your email:
h
orhelp
: Display help informationq
orquit
: Quit the email clientd
ordelete
: Delete the current messager
orreply
: Reply to the current messagef
orforward
: Forward the current messagep
orprint
: Print the current message
Example usage
Here's an example of how to use the mail
command to send and receive email:
$ mail -s "Hello" [email protected]
Subject: Hello
Hello, this is a test email.
^D
$ mail
Mail version 8.1.2 02/02/2021
Type? for help
"Mail" is on the inside.
There are 2 messages in your mailbox.
1 [email protected]
2 [email protected]
1 [email protected]
From [email protected] Wed Feb 2 14:30:00 2023
Subject: Hello
Hello, this is a test email.
2 [email protected]
From [email protected] Wed Feb 2 14:30:00 2023
Subject: Re: Hello
Hello back!
? q
In this example, we first use the mail
command to send an email to [email protected]
with the subject "Hello". We then use the mail
command again to receive email, and display the list of messages in our mailbox. We can then use the various commands to manage our email, such as deleting, replying, or forwarding messages.