Recently, after logging in to the command line, I got a message saying I have new mail. A few minutes with Google, and I entered in "cat /var/spool/mail/root" and I was reading notifications I thought would be important to know. How can I get these sent to my email address?
Thanks!
Replies (4)
TurnKey has Postfix pre-installed
Reply 1I appreciate the response. I
Reply 2I appreciate the response. I followed the directions. However, when I get to:
echo test | mail -s "test message" root
I get:
-bash: mail: command not found
Should I use something besides 'mail' to test? Is there something not installed I need to install? I'm guessing postfix is installed, as it seems to restart when I do 'service postfix restart'.
Sorry my bad...
Reply 3I was in a rush and I didn't read through it properly... If you want to use the 'mail' command then you'll need to install the mailutils package. The alias set up part of that post, should be fine though...
Having said that, for your purposes you don't need to install mailutils if you just want to test your config... You can use sendmail. The format is a little different though. To just send a quick and dirty test (with no subject line) try this:
echo this is a test | sendmail root
Note that unless you have a proper domain name set up, it will probably go directly to your spam/junk folder...
FWIW if you want to send a proper email with a subject etc you can do that something like this:
sendmail recipient@example.com <<EOF subject:subject line goes here from:whoever-you-want-it-from@wherever.com Message Body here... EOF
Or put the text (inc subject and from lines if you want to have them) in a file and use sendmail like this:
sendmail recipient@example.com < email.txt
By default TurnKey appliances can send email
Reply 4The easiest way to reliably send emails is to configure your server to relay emails a remote SMTP. Have a look at the docs.
Once you have that configured and working then you can go on to configure it to receive emails (and then pass them on). TBH I've never done that before so I'm not sure what is involved. If you keep in mind that TurnKey is Debian under the hood then you should find tons of info online. Please post back on your progress. I'd be really interested to hear and no doubt others could benefit from your experience.
But it is not configured to send anywhere (as you've discovered). To set it up so it emails you the stuff you want to know about google found me a good link that gives a pretty good rundown. The instructions are specifically for an Ubuntu server, but as TurnKey is built on Debian and Ubuntu is something of a Debian derivative also it should be totally relevant. FWIW I googled "get root email forwarded linux server", the link was the 2nd result.