Sending Email Through Console

$ echo "foobar" | mail -s "testing" [email protected]
The program 'mail' can be found in the following packages:
* heirloom-mailx
* mailutils
Try: apt-get install 

So, I was given two choices. Which one? I ended up picking mailutils because of dependency of Exim.
$ sudo -s
# sudo apt-get update; sudo apt-get upgrade;
# sudo apt-get install mailutils exim4-daemon-light
# dpkg-reconfigure exim4-config
- General type of mail configuration: internet site
- System mail name: foobar
- IP-addresses to listen on for incoming SMTP connections: ; ::1
- Other destinations for which mail is accepted: foobar; localhost.localdomain; localhost
- Domains to relay mail for:
- Machines to relay mail for:
- Keep number of DNS-queries minimal (Dial-on-Demand) : 
- Delivery method for local mail: mbox format in /var/mail
- Split configuration into smaller files: 

To test.
$ exim -bt [email protected]

R: dnslookup for [email protected]
[email protected]
router = dnslookup, transport = remote_smtp
host [] MX=10
$ echo "foobar" | mail -s "testing" [email protected]
$ sudo tail -f /var/log/exim4/mainlog

To use BCC or CC, you must install bsd-mailx package, the default GNU mailutils package does not support this.
$ sudo apt-get install bsd-mailx

Carbon Copy (CC).
$ echo "testing cc email" | mail -s "testing email cc" -c [email protected] [email protected]

Blind Carbon Copy (BCC).
$ echo "testing bcc email" | mail -s "testing email bcc" -b [email protected] [email protected]

Thanks to, you can check the email inbox at and

No comments:

Post a Comment