Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to send email with mail command, but it didn't work.

I use the following command :

mail -v -s "test"

then the terminal will always wait and no response. Also, there is nothing in the /var/log/mail Can anyone help me ?


By the way, my operating system is debian

share|improve this question

migrated from Apr 13 '12 at 0:31

This question came from our site for professional and enthusiast programmers.

Also, I can ping . – yaronli Apr 12 '12 at 6:02
up vote 3 down vote accepted

After that command, the process running mail is waiting for input on stdin, that you should end with Ctrl-D (end of file).

You can also pipe or redirect or use a here document

Exemple of using a pipe:

 date | mail -s "now is"

Typing a message

 mail -s "a message"
 body of your message
 end it with Ctrl-D

Redirecting a file containing the body

 mail -s "a message in file" < mailbody.txt

Using a here document

 mail -s "a here doc" <<ENDMSG
    this is the here doc
    ended by the line below
share|improve this answer

mail is an interactive program if you don't feed something into the standard input. Therefore you have to interactively enter some message body and finish the text by a line containing only a ..


mail -v -s "test"
Some text

Or you could pipe some text into mail's standard input:

echo "some text" | mail -v -s "test"
share|improve this answer
Thanks, got it. – yaronli Apr 12 '12 at 7:06

You must log in to answer this question.