How to Send an Email Using Sendmail Command in Linux

How to Send an Email Using Sendmail Command in Linux

I tried the below two commands. 1) From: mail_id To: Recepient_mail_id Hi, this is my message, and I'm sending it to you! . 2) echo "My message" | sendmail -s subject Receipient_mail_id

But didn't get any mail to the receipient's mail address.

SMTP server is installed on another server ans it is in up and running. So can anyone help me out on how to send a test email through that SMTP server using sendmail or smtp commands?

2 Answers

1. Using sendmail Command:

Created a file with email content:

$cat /tem/email.txt

Subject: Terminal Email Send

Email Content line 1

Email Content line 2

Now send email using the following command:

$sendmail < /tem/email.txt

Sarah Jenkins
Author

Sarah Jenkins

Sarah Jenkins is a veteran tech journalist with over 12 years of experience covering artificial intelligence, mobile innovations, and digital ethics. Her insights have appeared in leading technology publications worldwide.