Sending Email Through Console

$ echo "foobar" | mail -s "testing" foobar@mailinator.net
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: 127.0.0.1 ; ::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 foobar@mailinator.net

R: dnslookup for foobar@mailinator.net
foobar@mailinator.net
router = dnslookup, transport = remote_smtp
host mailinator.net [66.135.37.96] MX=10
$ echo "foobar" | mail -s "testing" foobar@mailinator.net
$ 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 foobar@mailinator.com barfoo@mailinator.com

Blind Carbon Copy (BCC).
$ echo "testing bcc email" | mail -s "testing email bcc" -b foobar@mailinator.com barfoo@mailinator.com

Thanks to mailinator.com, you can check the email inbox at http://barfoo.mailinator.com and http://foobar.mailinator.com.

No comments:

Post a Comment