How to send email through a Terminal window

emailterminal

I'm trying to figure out some basic Terminal commands, so I thought I'd try out 'mail.'

I opened a Terminal window and entered the following:
mail (my email address)
(The Terminal then said "Subject:" without quotes) so I entered "test" without quotes.

"This is a test message" without quotes

I then ended the message by typing . and enter, but nothing has send to my inbox.

Best Answer

You did not specify which inbox you checked, but if you use mail <your mac userid>, you can then read that mail by running the mail command without any arguments. I am not sure how useful this might be, but it does work.

man mail from a shell prompt will give you more background info into the mail command.

If you are looking to send email to an external (SMTP) mail server from a shell prompt (like the one in the Terminal window), you will need to use a message transfer agent or MTA. This is something far more useful, although it requires much more setup overhead.

Alternatively, you might be able to use Applescript and/or Automator to automate sending messages through Mail.app through a previously configured email account.