How to send mail from Linux system

Use the below command to send mail from a Linux server to a user email-id:

# echo “this is the body of the email” | mailx -s “test mail” -r “From” -S smtp=”your-smtp” xyz@domain123.com

-s =         Specifies the subject.
-r =         Email sent from.
-S =        Specifies the smtp server.

We can also add the configuration in mailx config file  /etc/mail.rc

set smtp=your.smtp.server

set from=”from email address”

Then run the mailx command and then enter the body of the email, hit enter, and finally press Ctrl+D to deliver it.


# mailx -vvv -s “email subject”  external-email-address

<Body of the email>


Ctrl D to deliver the message

Leave a Reply

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