10

For some reason, when I send mail with mail -s 'test email' tomyrealemail@myrealwebsite.com It prints out Cc: after I press enter and I can't do anything. I tried pressing . and it still is stuck. I'm trying to setup Amazon SES on Ubuntu

muru
  • 193,181
  • 53
  • 473
  • 722
Ryan Glenn
  • 201
  • 3
  • 4
  • 3
    Have you tried to press Enter ? – Soren A Jun 15 '21 at 22:36
  • 4
    Don't use the `mail` program. There's no need to. If you want to send mail by a human user, use "real" email client like `mutt`. If you want to send mail programatically from script, use `/usr/sbin/sendmail`, as `mail` internally does. In both cases the `mail` program is unneeded. – raj Jun 15 '21 at 23:19

2 Answers2

26

It is not hung. It is waiting for you to type in your message. Normally you can just send a command line email like:

echo "This is a test message" | mail -s 'test email' tomyrealemail@myrealwebsite.com

But if you just do mail -s 'test email' tomyrealemail@myrealwebsite.com the next part will be the Cc: or Carbon Copy email. If none, just press Enter.

Then just type in whatever body to the message you want to send, then as soon as you are done press Enter, then press Ctrl+D to send the message.

Hope this helps!

Terrance
  • 39,774
  • 7
  • 116
  • 176
1

You can just put '< /dev/null' ate the end of your command like this:

mail -s 'test email' tomyrealemail@myrealwebsite.com < /dev/null

It will send your message without any body.