Centos – Unix mail -s command hangs without send

apache-2.2centosemail

I know the common command to send email from shell is:

mail -s 'Some Subject' recipient@domain.com

When I do this however, things just hang. No errors returned, no messages sent and seemingly nothing put in the qmail queue. When I try to email my personal email address, the thing just hangs and does not create any entries in the qmail log files.

Are there other things I could be checking to see what the issue might be?

Best Answer

It's waiting for you to type in the message body.

Once you finish typing the message body, you can terminate the entry by either hitting ctrl-D on a new line, or having a "." (a period) as the first character of a new line.

You will then get a prompt for the "CC" if you want to add any addresses for the CC field.

After you enter that, or hit ENTER, it will send.

Example:

$ mail -s "Test message" recipient@example.com
This is a test message
.
Cc: 
$ 

You can also pass in a message body via stdin, e.g., cat /path/to/file.txt > mail -s "Test Message" recipient@domain.com, and the message body will be the contents of file.txt. This works better if file.txt is plaintext.