It's useful to be able to send email from the command line. As well as being an occasionally useful timesaver, it's handy for automation. For example, my computer sends me an email if it fails to complete a backup for whatever reason.
There are lots of tools for this on Linux but for ease of setup I can recommend mutt + Google Apps. Assuming you have a Google Apps account (you can of course also do this with a standard GMail account):
There are lots of tools for this on Linux but for ease of setup I can recommend mutt + Google Apps. Assuming you have a Google Apps account (you can of course also do this with a standard GMail account):
- Add a user to Google Apps. For example, if your PC is called "andromeda" and your domain is "example.com", you could add a user "andromeda@example.com". Or you could add a user for a specific task such as "backup@example.com".
- Enable IMAP access for this user.
- Install mutt: "sudo apt-get install mutt".
- Set up mutt to access GMail (here is a nice simple guide). Note that when editing .muttrc that for Google Apps the imap username is in the form username@domain, and the smtp_url is of the form username@domain@smtp.gmail.com:587 (yep, you have two "@"s in the line, even if that does look a bit weird!) Note that you may want to set this up on your root account if you're using it to notify you of backup failures etc.
- echo "Test mail" | mutt -s "Chimp test" you@example.com
- Voila!
No comments:
Post a Comment