Sign up ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm currently trying to send mails via bash script on Linux. I searched the internet and found this code:

echo "This is my body" | mail -s"this is my header" thisis@my.mail

I don't get any response either in the bash script nor when I type it directly in the command line. I waited for at least 3 hours now and still got no mail.

I just found that the log says stat=Deferred: Connection timed out with when sending to my Mail address but also has some entries with to<> and stat=Sent

share|improve this question
You need to configure mail on your machine before you can expect it to work. Particularly, you'll need to configure your machine to forward Internet mail to your ISP's mail server. – David Schwartz Oct 24 '13 at 15:56
Ohh, ok, I didn't know that most internet sources say it works out of the box – Fanvaron Oct 24 '13 at 15:57
How would it know where to send the mail? There's no "mail server discovery" protocol. – David Schwartz Oct 24 '13 at 16:00

2 Answers 2

The command—in and of itself—you are showing as an example is correct will work:

echo "This is my body" | mail -s"this is my header" thisis@my.mail

But you need to have some kind of local MTA (mail transfer agent) installed on the Linux machine you are attempting to do this on before it can work. On Ubuntu setting this up is as simple as installing Postfix and some related mail utilities like this:

sudo aptitude install postfix mailutils

Then after that is installed your mail command—as well as others—should work on the command line of that Linux server.

share|improve this answer

You can try mutt command as follows according to this site:

echo "<message body>" | mutt -s "<subject>" -a "<optional attachment>" -e "my_hdr From:<from address>" -- <recipients list separated by space>
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.