I used the following command to send an email

echo "Body of the mail" | mail -s "subject" "[email protected]"

The first time I ran it, it returned an error saying the program mail is not installed. After searching a bit, I fired the following command and it seems to have installed the program mail.

sudo apt-get install mailutils

I again tried to send the mail. This time the command did not return any error (I used $? to check the return value of the command.) So I thought the mail was sent successfully. However, I have not received it in my mailbox. I checked the junk/spam folders too, before anyone points that out.

What could be the reason?

I ask this question because there seems to be some caveat which no one talks about while using the mail command. All the answers I've seen so far just give the command to be used. But is there any setting that must be done before one can send an email from Bash?


1 Answer 1


You must install Postfix and configure it.

  • I'd appreciate some more information about that. Commented Mar 3, 2017 at 6:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .