So you want to know when your monitoring system fails, or your cron jobs don’t run? Add this to your crontab:
Now install a mail-sending agent. I like ‘nullmailer‘, which is much smaller than most mail-sending agents. It can’t receive or forward mail, only send it, which is what I like about it. No chance of a spammer using my server for something nasty.
The way I have it set up, I’ll have a server (avalanche) sending all email from one address (email@example.com) to one email (firstname.lastname@example.org), and that’s it. Here’s my setup on debian:
sudo apt-get install nullmailer
echo "email@example.com" | sudo tee /etc/nullmailer/adminaddr # all mail is sent to here, except for certain patterns
echo "nullmailer@`hostname`.za3k.com" | sudo tee /etc/nullmailer/allmailfrom # all mail is sent from here
echo "`hostname`.za3k.com" | sudo tee /etc/nullmailer/defaultdomain # superceded by 'allmailfrom' and not used
echo "`hostname`.za3k.com" | sudo tee /etc/nullmailer/helohost # required to connect to my server. otherwise default to 'me'
echo "smtp.za3k.com smtp --port=587 --starttls" | sudo tee /etc/nullmailer/remotes && sudo chmod 600 /etc/nullmailer/remotes
Now just run
echo "Subject: sendmail test" | /usr/lib/sendmail -v firstname.lastname@example.org to test and you’re done!
I’m posting my email setup here. The end result will:
- Use Postfix for SMTP
- Use Dovecot for IMAP and authentication
- Store usernames, email forwards, and passwords in a Postgres SQL database
- Only be accessible over encrypted channels
- Pass all common spam checks
- Support SMTP sending and IMAP email checking. I did not include POP3 because I don’t use it, but it should be easy to add
- NOT add spam filtering or web mail (this article is long enough as it is, maybe in a follow-up)
My newest site: http://moreorcs.com/
The site generates orc-themed emails for you, which you can get emailed at (completely insecurely, it’s just a web address at mailinator to see the content). Please check out mailinator’s site, it’s a really neat project.
- the last small poop orc (email@example.com)
- poop gross green blood thirsty orc
- 49 cross-eyed slightly intimidating poop dumb orcs
- the last slightly intimidating orc
- quite a lot of slightly intimidating small orcs
- 73 slightly intimidating small pretty orcs
- smelly orc
- a few orcs
- lots and lots and lots and lots and lots and lots of orcs
I set up an automatic archiver for gmail, using the special-purpose tool gm-vault. It was fairly straightforward, no tutorial here. The daily sync:
@daily cd ~gmail && cronic gmvault sync -d "/firstname.lastname@example.org" email@example.com
I’m specifying a backup folder here (-d) so I can easily support multiple accounts, one per line.
Cronic is a tool designed to make cron’s default email behavior better, so I get emailed only on actual backup failures.