Send mail unix
A classic!
In Unix, you can send an email using the mail
command. Here's a basic syntax:
mail [options] [email protected]
Here, [email protected]
is the email address of the person you want to send the email to.
Some common options:
-s subject
: sets the subject of the email-c
: allows you to compose a new email-a
: attaches a file to the email-b
: sends the email to the specified recipient(s) in the "To" field-c
: sends the email to the specified recipient(s) in the "CC" field
Here's an example:
mail -s "Hello from Unix" [email protected]
This will open a text editor where you can compose your email. When you're done, save the file and exit the editor. The email will be sent to the specified recipient.
If you want to send an email with a specific body, you can use the -c
option:
mail -c -s "Hello from Unix" [email protected]
This will open a text editor where you can compose your email. When you're done, save the file and exit the editor. The email will be sent to the specified recipient.
You can also use the mailx
command, which is similar to mail
, but has more features:
mailx -s "Hello from Unix" [email protected]
Some other options:
-a
: attaches a file to the email-b
: sends the email to the specified recipient(s) in the "To" field-c
: sends the email to the specified recipient(s) in the "CC" field-f
: specifies the sender's email address-r
: specifies the recipient's email address
For example:
mailx -a attachment.txt -s "Hello from Unix" [email protected]
This will attach the file attachment.txt
to the email and send it to the specified recipient.
Note: The mail
and mailx
commands are usually available on most Unix-like systems, including Linux and macOS. However, the exact syntax and options may vary depending on the specific system and version you're using.