problems about the mail command in linux

1

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

yaronli

Posted 2012-04-12T06:01:22.010

Reputation:

Also, I can ping smtp.163.com . – None – 2012-04-12T06:02:32.727

Answers

3

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

Basile Starynkevitch

Posted 2012-04-12T06:01:22.010

Reputation: 1 022

4

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

bmk

Posted 2012-04-12T06:01:22.010

Reputation: 1 735