Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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 ?

Thanks

By the way, my operating system is debian

share|improve this question

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
add comment

2 Answers

up vote 2 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
 ENDMSG
share|improve this answer
add comment

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 ..

E.g.:

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
share|improve this answer
    
Thanks, got it. –  yaronli Apr 12 '12 at 7:06
add comment

Your Answer

 
discard

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