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

I use the following command :

mail -v -s "test" jidalyg_8711@163.com

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

migrated from stackoverflow.com Apr 13 '12 at 0:31

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

  • Also, I can ping smtp.163.com . – 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" jidalyg_8711@163.com

Typing a message

 mail -s "a message" jidalyg_8711@163.com
 body of your message
 end it with Ctrl-D

Redirecting a file containing the body

 mail -s "a message in file" jidalyg_8711@163.com < mailbody.txt

Using a here document

 mail -s "a here doc" jidalyg_8711@163.com <<ENDMSG
    this is the here doc
    ended by the line below

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" jidalyg_8711@163.com
Some text

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

echo "some text" | mail -v -s "test" jidalyg_8711@163.com

Your Answer


By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.