sendmail command examples

Before all of the things you need Linux and something like Postfix installed. I test these examples on Ubuntu.

In the first example, we will create a file with the message and then we’ll send it to the recipient with help of sendmail command.

Create the file /tmp/mail.txt that contains the text and a new line at the end:

  sudo nano /tmp/mail.txt
Subject: the subject
This is the text of the message.
[new line]

Then type this:

  sendmail recipient@gmail.com < /tmp/mail.txt