Using command line mail in Ubuntu

Q I'd like to use the shell for my email. Can you tell me how this can be set up? I currently use Ubuntu 6.10.

A Do you mean you want to run a mail client within your shell, or do you want to be able to send mails from shell scripts? There are several terminal-based mail programs, the most popular of which is Mutt (www.mutt. org). Mutt is included in Ubuntu's main repository, so you can install it from Synaptic. If you want to send emails from a Bash script, the mailx command is the simplest solution, and is probably already installed on your system. This program mails whatever it receives on standard input to a specified address. For example:

echo "Hello World" | -s "Obvious example" me@example.com

The subject of the mail is given with -s (use quotes if it contains spaces), and everything received on standard input forms the body of the mail, so it's good for mailing program output.

Follow us on Identi.ca or Twitter

Username:   Password:
Create Account | About TuxRadar