Wednesday 16 May 2018

Mail Command on CentOS Linux

Mail command is used to send emails from linux terminal.

If you already have mail command then it is ok. If not, you have to install the mailx package.

To install the package,

[root@testing-server]# yum install mailx

After install the package you can use the mail command to send a mail.

To send a mail,

[root@testing-server]# mail be.manivel@gmail.com
Subject: Test mail
First test mail
.
EOT
[root@testing-server]#

To send a mail with attachment,

[root@testing-server]# mail -a test_mail.txt be.manivel@gmail.com
Subject: Test mail with attachement
I have attached a test mail content
.
EOT
[root@testing-server]#

To send a mail from specific user address,

[root@testing-server]# mail -r manivel@example.com -s "Test mail with specific user address" be.manivel@gmail.com
First test mail
.
EOT
[root@testing-server]#


No comments:

Post a Comment